mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-04-23 23:48:46 +00:00
* GSWeb/GSWUtils.m
fix rangeOfData:range: * GSWExtensions/GSWCollapsibleComponentContent.gswc/GSWCollapsibleComponentContent.gswd set framework binding * GSWExtensions/GSWCollapsibleComponentContent.[hm] handle framework binding * GSWExtensions/GSWPageRestorationErrorPage.gswc/GSWPageRestorationErrorPage.gswd set framework binding * GSWExtensions/GSWSessionCreationErrorPage.gswc/GSWSessionCreationErrorPage.gswd set framework binding * GSWExtensions/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.gswd set framework binding * GSWeb/GSWApplication.[hm] add -frameworkNameGSWExtensions * GSWeb/GSWPasswordField.m respect GNUstep coding standard (curly brackets placement, etc.) * GSWeb/GSWPasswordField.h remove unneeded declarations * GSWeb/GSWHiddenField.m fix * GSWeb/GSWHiddenField.h remove unneeded declarations * GSWeb/GSWString.m fix appendToResponse:inContext: when formattedValue is nil respect GNUstep coding standard (curly brackets placement, etc.) * GSWeb/GSWTemplateParser.m: fix exception error messages * GSWeb/GSWPopUpButton.m use GSWAssignAndRemoveAssociation() in initWithName:associations:template: clean code * GSWeb/GSWRepetition.m respect GNUstep coding standard (curly brackets placement, etc.) reimplement startIndex and stopIndex bindings clean code * GSWeb/GSWCheckBoxList.m fix -initWithName:...: prefix__Key duplicate, _value * GSWeb.framework/GSWRadioButtonList.m respect GNUstep coding standard (curly brackets placement, etc.) use GSWAssignAndRemoveAssociation() in initWithName:associations:template: Fix bug in -initWithName (valueAssoc) Fix bug in _slowTakeValuesFromRequest: (call NSStringWithObject()) * GSWeb/GSWTextField.m respect GNUstep coding standard (curly brackets placement, etc.) use GSWAssignAndRemoveAssociation() in initWithName:associations:template: Fix bug (call NSStringWithObject()) * GSWeb/GSWText.m respect GNUstep coding standard (curly brackets placement, etc.) clean code use GSWAssignAndRemoveAssociation() in initWithName:associations:template: Fix bug (call NSStringWithObject()) * GSWeb/GSWCheckBox.m respect GNUstep coding standard (curly brackets placement, etc.) clean code use GSWAssignAndRemoveAssociation() in initWithName:associations:template: * GSWeb/GSWRadioButton.m respect GNUstep coding standard (curly brackets placement, etc.) clean code use GSWAssignAndRemoveAssociation() in initWithName:associations:template: * GSWeb.framework/GSWInput.h remove initWithName:associations:contentElements: * GSWeb.framework/GSWInput.m respect GNUstep coding standard (curly brackets placement, etc.) use GSWAssignAndRemoveAssociation() in initWithName:associations:template: ensure name is a string in -nameInContext: fix name escaping in -_appendNameAttributeToResponse: ensure value is a string in _appendValueAttributeToResponse: remove initWithName:associations:contentElements: * GSWeb/GSWHTMLDynamicElement.m respect GNUstep coding standard (curly brackets placement, etc.) ensure string conversion in -_finishInitialization rename variables to make code understandable * GSWeb/GSWConditional.m respect GNUstep coding standard (curly brackets placement, etc.) * GSWeb/GSWActionImage.m respect GNUstep coding standard (curly brackets placement, etc.) fix secure stuff ensure string conversion * GSWeb/GSWActionURL.m respect GNUstep coding standard (curly brackets placement, etc.) ensure string conversion * GSWeb/GSWBody.h remove uneeded declarations * GSWeb/GSWBody.m remove uneeded stuff fix initWithName:... * GSWeb.framework/GSWBrowser.m respect GNUstep coding standard (curly brackets placement, etc.) use GSWAssignAndRemoveAssociation() in initWithName:associations:template: clean code rename variables to make code understandable Fix bugs * GSWeb.framework/GSWFileUpload.m respect GNUstep coding standard (curly brackets placement, etc.) use GSWAssignAndRemoveAssociation() in initWithName:associations:template: * GSWeb/GSWFrame.h remove uneeded declarations * GSWeb/GSWFrame.m respect GNUstep coding standard (curly brackets placement, etc.) clean code * GSWeb/GSWGenericContainer.h remove uneeded declarations change inheritence * GSWeb/GSWGenericContainer.m respect GNUstep coding standard (curly brackets placement, etc.) clean code * GSWeb/GSWGenericElement.h remove uneeded declarations change inheritence * GSWeb/GSWGenericElement.m respect GNUstep coding standard (curly brackets placement, etc.) clean code * GSWeb/GSWForm.h remove uneeded declarations * GSWeb/GSWForm.m respect GNUstep coding standard (curly brackets placement, etc.) use GSWAssignAndRemoveAssociation() in initWithName:associations:template: clean code ensure string conversion * GSWeb/GSWHTMLURLValuedElement.m respect GNUstep coding standard (curly brackets placement, etc.) use GSWAssignAndRemoveAssociation() in initWithName:associations:template: clean code ensure string conversion finish appendAttributesToResponse:inContext implementation * GSWeb/GSWHyperlink.m respect GNUstep coding standard (curly brackets placement, etc.) use GSWAssignAndRemoveAssociation() in initWithName:associations:template: clean code ensure string conversion * GSWeb/GSWImage.m respect GNUstep coding standard (curly brackets placement, etc.) use GSWAssignAndRemoveAssociation() in initWithName:associations:template: clean code * GSWeb/GSWClientSideScript.h remove uneeded declarations change inheritence add -setLanguage * GSWeb/GSWJavaScript.m clean and update code * GSWeb/GSWSubmitButton.m respect GNUstep coding standard (curly brackets placement, etc.) use GSWAssignAndRemoveAssociation() in initWithName:associations:template: clean code * GSWeb/GSWImageButton.m respect GNUstep coding standard (curly brackets placement, etc.) use GSWAssignAndRemoveAssociation() in initWithName:associations:template: * GSWeb/GSWSwitchComponent.m clean and update code * GSWeb/GSWJavaScript.m clean and update code * GSWeb/GSWContext.m clean & fix -computeQueryDictionaryWithPath:queryDictionary:otherQueryDictionary: fix componentActionURL... methods * GSWeb/GSWHTTPIO.m: use GSWeb_appendStringWithImpPtr() * GSWeb/GSWActionURL.h remove uneeded declarations * GSWeb/GSWPrivate.h add GSWeb_objectAtIndexWithImpPtr * GSWDatabase/WODisplayGroup.m Don't raise validation exceptions in _qualifierForKey:value:operatorSelector: git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@37899 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
af78e8fe37
commit
97e527ebed
79 changed files with 4773 additions and 4680 deletions
162
ChangeLog
162
ChangeLog
|
@ -1,3 +1,165 @@
|
|||
2014-05-22 Manuel Guesdon <mguesdon@orange-concept.com>
|
||||
* GSWeb/GSWUtils.m
|
||||
fix rangeOfData:range:
|
||||
* GSWExtensions/GSWCollapsibleComponentContent.gswc/GSWCollapsibleComponentContent.gswd
|
||||
set framework binding
|
||||
* GSWExtensions/GSWCollapsibleComponentContent.[hm]
|
||||
handle framework binding
|
||||
* GSWExtensions/GSWPageRestorationErrorPage.gswc/GSWPageRestorationErrorPage.gswd
|
||||
set framework binding
|
||||
* GSWExtensions/GSWSessionCreationErrorPage.gswc/GSWSessionCreationErrorPage.gswd
|
||||
set framework binding
|
||||
* GSWExtensions/GSWSessionRestorationErrorPage.gswc/GSWSessionRestorationErrorPage.gswd
|
||||
set framework binding
|
||||
* GSWeb/GSWApplication.[hm]
|
||||
add -frameworkNameGSWExtensions
|
||||
* GSWeb/GSWPasswordField.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
* GSWeb/GSWPasswordField.h
|
||||
remove unneeded declarations
|
||||
* GSWeb/GSWHiddenField.m
|
||||
fix
|
||||
* GSWeb/GSWHiddenField.h
|
||||
remove unneeded declarations
|
||||
* GSWeb/GSWString.m
|
||||
fix appendToResponse:inContext: when formattedValue is nil
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
* GSWeb/GSWTemplateParser.m:
|
||||
fix exception error messages
|
||||
* GSWeb/GSWPopUpButton.m
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
clean code
|
||||
* GSWeb/GSWRepetition.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
reimplement startIndex and stopIndex bindings
|
||||
clean code
|
||||
* GSWeb/GSWCheckBoxList.m
|
||||
fix -initWithName:...: prefix__Key duplicate, _value
|
||||
* GSWeb.framework/GSWRadioButtonList.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
Fix bug in -initWithName (valueAssoc)
|
||||
Fix bug in _slowTakeValuesFromRequest: (call NSStringWithObject())
|
||||
* GSWeb/GSWTextField.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
Fix bug (call NSStringWithObject())
|
||||
* GSWeb/GSWText.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
clean code
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
Fix bug (call NSStringWithObject())
|
||||
* GSWeb/GSWCheckBox.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
clean code
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
* GSWeb/GSWRadioButton.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
clean code
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
* GSWeb.framework/GSWInput.h
|
||||
remove initWithName:associations:contentElements:
|
||||
* GSWeb.framework/GSWInput.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
ensure name is a string in -nameInContext:
|
||||
fix name escaping in -_appendNameAttributeToResponse:
|
||||
ensure value is a string in _appendValueAttributeToResponse:
|
||||
remove initWithName:associations:contentElements:
|
||||
* GSWeb/GSWHTMLDynamicElement.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
ensure string conversion in -_finishInitialization
|
||||
rename variables to make code understandable
|
||||
* GSWeb/GSWConditional.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
* GSWeb/GSWActionImage.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
fix secure stuff
|
||||
ensure string conversion
|
||||
* GSWeb/GSWActionURL.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
ensure string conversion
|
||||
* GSWeb/GSWBody.h
|
||||
remove uneeded declarations
|
||||
* GSWeb/GSWBody.m
|
||||
remove uneeded stuff
|
||||
fix initWithName:...
|
||||
* GSWeb.framework/GSWBrowser.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
clean code
|
||||
rename variables to make code understandable
|
||||
Fix bugs
|
||||
* GSWeb.framework/GSWFileUpload.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
* GSWeb/GSWFrame.h
|
||||
remove uneeded declarations
|
||||
* GSWeb/GSWFrame.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
clean code
|
||||
* GSWeb/GSWGenericContainer.h
|
||||
remove uneeded declarations
|
||||
change inheritence
|
||||
* GSWeb/GSWGenericContainer.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
clean code
|
||||
* GSWeb/GSWGenericElement.h
|
||||
remove uneeded declarations
|
||||
change inheritence
|
||||
* GSWeb/GSWGenericElement.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
clean code
|
||||
* GSWeb/GSWForm.h
|
||||
remove uneeded declarations
|
||||
* GSWeb/GSWForm.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
clean code
|
||||
ensure string conversion
|
||||
* GSWeb/GSWHTMLURLValuedElement.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
clean code
|
||||
ensure string conversion
|
||||
finish appendAttributesToResponse:inContext implementation
|
||||
* GSWeb/GSWHyperlink.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
clean code
|
||||
ensure string conversion
|
||||
* GSWeb/GSWImage.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
clean code
|
||||
* GSWeb/GSWClientSideScript.h
|
||||
remove uneeded declarations
|
||||
change inheritence
|
||||
add -setLanguage
|
||||
* GSWeb/GSWJavaScript.m
|
||||
clean and update code
|
||||
* GSWeb/GSWSubmitButton.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
clean code
|
||||
* GSWeb/GSWImageButton.m
|
||||
respect GNUstep coding standard (curly brackets placement, etc.)
|
||||
use GSWAssignAndRemoveAssociation() in initWithName:associations:template:
|
||||
* GSWeb/GSWSwitchComponent.m
|
||||
clean and update code
|
||||
* GSWeb/GSWJavaScript.m
|
||||
clean and update code
|
||||
* GSWeb/GSWContext.m
|
||||
clean & fix -computeQueryDictionaryWithPath:queryDictionary:otherQueryDictionary:
|
||||
fix componentActionURL... methods
|
||||
* GSWeb/GSWHTTPIO.m:
|
||||
use GSWeb_appendStringWithImpPtr()
|
||||
* GSWeb/GSWActionURL.h
|
||||
remove uneeded declarations
|
||||
* GSWeb/GSWPrivate.h
|
||||
add GSWeb_objectAtIndexWithImpPtr
|
||||
* GSWDatabase/WODisplayGroup.m
|
||||
Don't raise validation exceptions in _qualifierForKey:value:operatorSelector:
|
||||
2014-05-06 Manuel Guesdon <mguesdon@orange-concept.com>
|
||||
* GSWeb/GSWCheckBoxList.m
|
||||
fix appendToResponse:inContext:
|
||||
|
|
|
@ -2360,27 +2360,31 @@ createObjectFailedForDataSource:_dataSource];
|
|||
value:(id)value
|
||||
operatorSelector:(SEL)operatorSelector
|
||||
{
|
||||
EOClassDescription* cd=nil;
|
||||
EOQualifier* qualifier=nil;
|
||||
NSException* validateException=nil;
|
||||
|
||||
// Get object class description
|
||||
cd=[_dataSource classDescriptionForObjects];
|
||||
EOClassDescription* cd=[_dataSource classDescriptionForObjects];
|
||||
|
||||
// Validate the value against object class description
|
||||
validateException=[cd validateValue:&value
|
||||
forKey:key];
|
||||
|
||||
if (validateException)
|
||||
{
|
||||
[validateException raise]; //VERIFY
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString* qualifierClassName=[_queryKeyValueQualifierClassName objectForKey:key];
|
||||
Class qualifierClass=Nil;
|
||||
forKey:key];
|
||||
|
||||
if ([qualifierClassName length]>0)
|
||||
if (validateException)
|
||||
{
|
||||
if ([[validateException name] isEqualToString:EOValidationException])
|
||||
{
|
||||
//Don't raise exception, just log it
|
||||
NSLog(@"Exception during value validation for key: '%@': %@",key,validateException);
|
||||
}
|
||||
else
|
||||
[validateException raise];
|
||||
}
|
||||
|
||||
NSString* qualifierClassName=[_queryKeyValueQualifierClassName objectForKey:key];
|
||||
Class qualifierClass=Nil;
|
||||
|
||||
if ([qualifierClassName length]>0)
|
||||
{
|
||||
qualifierClass=NSClassFromString(qualifierClassName);
|
||||
NSAssert1(qualifierClass,@"No qualifier class named %@",qualifierClassName);
|
||||
|
@ -2388,85 +2392,84 @@ createObjectFailedForDataSource:_dataSource];
|
|||
@"Qualifier class %@ instance does not responds to -initWithKey:operatorSelector:value:",
|
||||
qualifierClassName);
|
||||
}
|
||||
else
|
||||
qualifierClass=[EOKeyValueQualifier class];
|
||||
|
||||
// If the selector is the equal operator
|
||||
if (sel_isEqual(operatorSelector, EOQualifierOperatorEqual))
|
||||
else
|
||||
qualifierClass=[EOKeyValueQualifier class];
|
||||
|
||||
// If the selector is the equal operator
|
||||
if (sel_isEqual(operatorSelector, EOQualifierOperatorEqual))
|
||||
{
|
||||
// Search if there's a specific defined operator for it
|
||||
NSString* operatorString=[_queryOperator objectForKey:key];
|
||||
|
||||
// If value is a string, try to do handle string specific operators
|
||||
if([value isKindOfClass:[NSString class]])
|
||||
{
|
||||
// 'Basic' equal operator
|
||||
if ([operatorString isEqualToString:@"is"])
|
||||
{
|
||||
operatorString = @"=";
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString* stringValue = (NSString*)value;
|
||||
// Other string operators don't care about empry string
|
||||
|
||||
if ([stringValue length]==0)
|
||||
{
|
||||
// So ends here and we'll return a nil qualifier
|
||||
key=nil;
|
||||
value=nil;
|
||||
operatorString=nil;
|
||||
}
|
||||
else if ([operatorString length]==0) // ==> defaultStringMatchOperator with defaultStringMatchFormat
|
||||
{
|
||||
value=[NSString stringWithFormat:_defaultStringMatchFormat,
|
||||
value];
|
||||
operatorString = _defaultStringMatchOperator;
|
||||
}
|
||||
else if ([operatorString isEqualToString:@"starts with"])
|
||||
{
|
||||
value=[NSString stringWithFormat:@"%@*",
|
||||
value];
|
||||
operatorString = _defaultStringMatchOperator;
|
||||
}
|
||||
else if ([operatorString isEqualToString:@"ends with"])
|
||||
{
|
||||
value=[NSString stringWithFormat:@"*%@",
|
||||
value];
|
||||
operatorString = _defaultStringMatchOperator;
|
||||
}
|
||||
else if([operatorString isEqualToString:@"contains"])
|
||||
{
|
||||
value=[NSString stringWithFormat:@"*%@*",
|
||||
value];
|
||||
operatorString = _defaultStringMatchOperator;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
// 'Basic' equal operator
|
||||
if ([operatorString isEqualToString:@"is"])
|
||||
{
|
||||
operatorString = @"=";
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString* stringValue = (NSString*)value;
|
||||
// Other string operators don't care about empry string
|
||||
|
||||
if ([stringValue length]==0)
|
||||
{
|
||||
// So ends here and we'll return a nil qualifier
|
||||
key=nil;
|
||||
value=nil;
|
||||
operatorString=nil;
|
||||
}
|
||||
else if ([operatorString length]==0) // ==> defaultStringMatchOperator with defaultStringMatchFormat
|
||||
{
|
||||
value=[NSString stringWithFormat:_defaultStringMatchFormat,
|
||||
value];
|
||||
operatorString = _defaultStringMatchOperator;
|
||||
}
|
||||
else if ([operatorString isEqualToString:@"starts with"])
|
||||
{
|
||||
value=[NSString stringWithFormat:@"%@*",
|
||||
value];
|
||||
operatorString = _defaultStringMatchOperator;
|
||||
}
|
||||
else if ([operatorString isEqualToString:@"ends with"])
|
||||
{
|
||||
value=[NSString stringWithFormat:@"*%@",
|
||||
value];
|
||||
operatorString = _defaultStringMatchOperator;
|
||||
}
|
||||
else if([operatorString isEqualToString:@"contains"])
|
||||
{
|
||||
value=[NSString stringWithFormat:@"*%@*",
|
||||
value];
|
||||
operatorString = _defaultStringMatchOperator;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ([operatorString length]==0)
|
||||
operatorString = @"=";
|
||||
}
|
||||
{
|
||||
if ([operatorString length]==0)
|
||||
operatorString = @"=";
|
||||
}
|
||||
operatorSelector = [qualifierClass operatorSelectorForString:operatorString];
|
||||
}
|
||||
|
||||
if (key || operatorSelector || value) // qualifier returned will be nil when we have to discard it
|
||||
|
||||
if (key || operatorSelector || value) // qualifier returned will be nil when we have to discard it
|
||||
{
|
||||
if (operatorSelector)
|
||||
{
|
||||
qualifier=[[[qualifierClass alloc]
|
||||
initWithKey:key
|
||||
operatorSelector:operatorSelector
|
||||
value:value] autorelease];
|
||||
}
|
||||
{
|
||||
qualifier=[[[qualifierClass alloc]
|
||||
initWithKey:key
|
||||
operatorSelector:operatorSelector
|
||||
value:value] autorelease];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"Error: Qualifier (%@) null selector for %@ %@ %@. Discard it !",
|
||||
qualifierClass,key,[_queryOperator objectForKey:key],value);
|
||||
}
|
||||
{
|
||||
NSLog(@"Error: Qualifier (%@) null selector for %@ %@ %@. Discard it !",
|
||||
qualifierClass,key,[_queryOperator objectForKey:key],value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return qualifier;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ Link: GSWHyperlink
|
|||
Image: GSWImage
|
||||
{
|
||||
filename = imageFileName;
|
||||
//framework = "GSWExtensions";
|
||||
framework = framework;
|
||||
alt = helpString;
|
||||
name = helpString;
|
||||
border = "0";
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
NSString* _tmpAnchorName;
|
||||
BOOL _isVisibleConditionPassed;
|
||||
BOOL _isVisible;
|
||||
NSString* _framework;
|
||||
NSString* _openedImageFileName;
|
||||
NSString* _closedImageFileName;
|
||||
NSString* _openedHelpString;
|
||||
|
|
|
@ -42,6 +42,7 @@ RCS_ID("$Id$")
|
|||
//-----------------------------------------------------------------------------------
|
||||
-(void)dealloc
|
||||
{
|
||||
DESTROY(_framework);
|
||||
DESTROY(_openedImageFileName);
|
||||
DESTROY(_closedImageFileName);
|
||||
DESTROY(_openedHelpString);
|
||||
|
@ -97,6 +98,19 @@ RCS_ID("$Id$")
|
|||
return nil;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
- (NSString*)framework
|
||||
{
|
||||
if (!_framework)
|
||||
{
|
||||
if ([self hasBinding:@"framework"])
|
||||
ASSIGN(_framework,([self valueForBinding:@"framework"]));
|
||||
else
|
||||
ASSIGN(_framework,([GSWApp frameworkNameGSWExtensions]));
|
||||
}
|
||||
return _framework;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
-(NSString*)imageFileName
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
ExclamationImage: GSWImage
|
||||
{
|
||||
filename = "exclamation.png";
|
||||
framework = "WOExtensions";
|
||||
framework = application.frameworkNameGSWExtensions;
|
||||
height="50";
|
||||
width="60";
|
||||
alt="exclamation sign"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
ExclamationImage: GSWImage
|
||||
{
|
||||
filename = "exclamation.png";
|
||||
framework = "WOExtensions";
|
||||
framework = application.frameworkNameGSWExtensions;
|
||||
height="50";
|
||||
width="60";
|
||||
alt="exclamation sign"
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
ExclamationImage: GSWImage
|
||||
{
|
||||
filename = "exclamation.png";
|
||||
framework = "WOExtensions";
|
||||
framework = application.frameworkNameGSWExtensions;
|
||||
height="50";
|
||||
width="60";
|
||||
alt="exclamation sign"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
ExclamationImage: GSWImage
|
||||
{
|
||||
filename = "exclamation.png";
|
||||
framework = "WOExtensions";
|
||||
framework = application.frameworkNameGSWExtensions;
|
||||
height="50";
|
||||
width="60";
|
||||
alt="exclamation sign"
|
||||
|
|
|
@ -33,10 +33,6 @@
|
|||
#define _GSWActionURL_h__
|
||||
|
||||
@interface GSWActionURL: GSWHyperlink
|
||||
-(id)initWithName:(NSString*)name
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template;
|
||||
|
||||
@end
|
||||
|
||||
#endif // _GSWActionURL_h__
|
||||
|
|
|
@ -37,88 +37,76 @@ RCS_ID("$Id$")
|
|||
//====================================================================
|
||||
@implementation GSWActionURL
|
||||
|
||||
-(id)initWithName:(NSString*)name
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
id me = [super initWithName:name
|
||||
associations:associations
|
||||
template:template];
|
||||
|
||||
return me;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)appendToResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
id fragment = nil;
|
||||
NSString * path = nil;
|
||||
NSString * url = nil;
|
||||
|
||||
GSWComponent * component = [context component];
|
||||
|
||||
if(_href != nil)
|
||||
{
|
||||
url = [_href valueInComponent:component];
|
||||
}
|
||||
|
||||
if(_directActionName != nil || _actionClass != nil)
|
||||
{
|
||||
[self _appendCGIActionURLToResponse:response
|
||||
inContext:context];
|
||||
} else {
|
||||
if(_action != nil || _pageName != nil)
|
||||
if (_directActionName != nil
|
||||
|| _actionClass != nil)
|
||||
{
|
||||
NSString * actionURL = [context componentActionURLIsSecure:[self secureInContext:context]];
|
||||
[response appendContentString:actionURL];
|
||||
|
||||
[self _appendQueryStringToResponse:response
|
||||
inContext:context
|
||||
requestHandlerPath:nil
|
||||
htmlEscapeURL:NO];
|
||||
|
||||
[self _appendFragmentToResponse: response inContext:context];
|
||||
} else {
|
||||
if(url != nil)
|
||||
{
|
||||
if (([url isRelativeURL]) && (![url isFragmentURL]))
|
||||
{
|
||||
path = [context _urlForResourceNamed:url inFramework:nil];
|
||||
if(path != nil)
|
||||
{
|
||||
GSWResponse_appendContentString(response,path);
|
||||
|
||||
} else {
|
||||
GSWResponse_appendContentAsciiString(response, [component baseURL]);
|
||||
GSWResponse_appendContentCharacter(response,'/');
|
||||
GSWResponse_appendContentString(response,url);
|
||||
}
|
||||
} else {
|
||||
GSWResponse_appendContentString(response,url);
|
||||
}
|
||||
[self _appendQueryStringToResponse:response
|
||||
inContext:context
|
||||
requestHandlerPath:nil
|
||||
htmlEscapeURL:NO];
|
||||
|
||||
[self _appendFragmentToResponse: response inContext:context];
|
||||
} else {
|
||||
if(_fragmentIdentifier != nil)
|
||||
{
|
||||
fragment = [_fragmentIdentifier valueInComponent:component];
|
||||
if (fragment != nil) {
|
||||
// NSLog(@"fragment is kind of class %@", NSStringFromClass([fragment class]));
|
||||
GSWResponse_appendContentString(response,fragment);
|
||||
[self _appendQueryStringToResponse:response
|
||||
inContext: context
|
||||
requestHandlerPath:@""
|
||||
htmlEscapeURL:NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
[self _appendCGIActionURLToResponse:response
|
||||
inContext:context];
|
||||
}
|
||||
else if (_action != nil
|
||||
|| _pageName != nil)
|
||||
{
|
||||
NSString * actionURL = [context _componentActionURLIsSecure:[self secureInContext:context]];
|
||||
GSWResponse_appendContentString(response,actionURL);
|
||||
|
||||
[self _appendQueryStringToResponse:response
|
||||
inContext:context
|
||||
requestHandlerPath:nil
|
||||
htmlEscapeURL:NO];
|
||||
|
||||
[self _appendFragmentToResponse: response
|
||||
inContext:context];
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWComponent* component = [context component];
|
||||
|
||||
NSString* url = NSStringWithObject([_href valueInComponent:component]);
|
||||
if (url != nil)
|
||||
{
|
||||
if ([url isRelativeURL]
|
||||
&& ![url isFragmentURL])
|
||||
{
|
||||
NSString* path = [context _urlForResourceNamed:url
|
||||
inFramework:nil];
|
||||
if(path != nil)
|
||||
GSWResponse_appendContentString(response,path);
|
||||
else
|
||||
{
|
||||
GSWResponse_appendContentAsciiString(response, [component baseURL]);
|
||||
GSWResponse_appendContentCharacter(response,'/');
|
||||
GSWResponse_appendContentString(response,url);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWResponse_appendContentString(response,url);
|
||||
}
|
||||
[self _appendQueryStringToResponse:response
|
||||
inContext:context
|
||||
requestHandlerPath:nil
|
||||
htmlEscapeURL:NO];
|
||||
|
||||
[self _appendFragmentToResponse: response
|
||||
inContext:context];
|
||||
}
|
||||
else if(_fragmentIdentifier != nil)
|
||||
{
|
||||
NSString* fragment = [_fragmentIdentifier valueInComponent:component];
|
||||
if (fragment != nil)
|
||||
{
|
||||
GSWResponse_appendContentString(response,NSStringWithObject(fragment));
|
||||
[self _appendQueryStringToResponse:response
|
||||
inContext: context
|
||||
requestHandlerPath:@""
|
||||
htmlEscapeURL:NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,16 +43,18 @@ static GSWAssociation * static_defaultBorderAssociation = nil;
|
|||
|
||||
@implementation GSWActiveImage
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GSWActiveImage class])
|
||||
{
|
||||
if (!static_sessionIDKey) {
|
||||
static_sessionIDKey = [[GSWApp sessionIdKey] retain];
|
||||
static_tempQueryKey = [[@"?" stringByAppendingString:static_sessionIDKey] retain];
|
||||
static_defaultBorderAssociation = [[GSWAssociation associationWithValue:@"0"] retain];
|
||||
{
|
||||
if (!static_sessionIDKey)
|
||||
{
|
||||
ASSIGN(static_sessionIDKey,([GSWApp sessionIdKey]));
|
||||
ASSIGN(static_tempQueryKey,([@"?" stringByAppendingString:static_sessionIDKey]));
|
||||
ASSIGN(static_defaultBorderAssociation,([GSWAssociation associationWithValue:@"0"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,212 +66,185 @@ static GSWAssociation * static_defaultBorderAssociation = nil;
|
|||
NSMutableDictionary * tempQueryAssociations = [NSMutableDictionary dictionary];
|
||||
GSWAssociation * tempAssociation = nil;
|
||||
|
||||
self = [super initWithName:@"input" associations:associations template: nil];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
tempAssociation = [_associations objectForKey:static_tempQueryKey];
|
||||
if (tempAssociation != nil) {
|
||||
[tempQueryAssociations setObject:tempAssociation
|
||||
forKey:static_sessionIDKey];
|
||||
[_associations removeObjectForKey: static_tempQueryKey];
|
||||
}
|
||||
|
||||
if ([static_sessionIDKey isEqualToString:GSWKey_SessionID[GSWebNamingConv]] == NO) {
|
||||
tempAssociation = [_associations objectForKey:GSWKey_QuestionMarkSessionID[GSWebNamingConv]];
|
||||
if (tempAssociation != nil) {
|
||||
[tempQueryAssociations setObject:tempAssociation
|
||||
forKey:GSWKey_SessionID[GSWebNamingConv]];
|
||||
[_associations removeObjectForKey:GSWKey_QuestionMarkSessionID[GSWebNamingConv]];
|
||||
}
|
||||
}
|
||||
|
||||
if ([tempQueryAssociations count] > 0) {
|
||||
_sessionIDQueryAssociations = [tempQueryAssociations retain];
|
||||
} else {
|
||||
DESTROY(_sessionIDQueryAssociations);
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
ASSIGN(_border, [_associations objectForKey: border__Key]);
|
||||
if (_border != nil) {
|
||||
[_associations removeObjectForKey: border__Key];
|
||||
}
|
||||
else {
|
||||
ASSIGN(_border,static_defaultBorderAssociation);
|
||||
}
|
||||
|
||||
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 ((self = [super initWithName:@"input"
|
||||
associations:associations
|
||||
template: nil]))
|
||||
{
|
||||
if (_actionClass != nil || _directActionName != nil || _href != nil)
|
||||
tempAssociation = [_associations objectForKey:static_tempQueryKey];
|
||||
if (tempAssociation != nil)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: If 'action' is specified, 'directActionName', 'actionClass', and 'href' must be nil.",
|
||||
__PRETTY_FUNCTION__];
|
||||
[tempQueryAssociations setObject:tempAssociation
|
||||
forKey:static_sessionIDKey];
|
||||
[_associations removeObjectForKey: static_tempQueryKey];
|
||||
}
|
||||
if ([_action isValueConstant])
|
||||
|
||||
if ([static_sessionIDKey isEqualToString:GSWKey_SessionID[GSWebNamingConv]] == NO)
|
||||
{
|
||||
[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)
|
||||
tempAssociation = [_associations objectForKey:GSWKey_QuestionMarkSessionID[GSWebNamingConv]];
|
||||
if (tempAssociation != 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__];
|
||||
[tempQueryAssociations setObject:tempAssociation
|
||||
forKey:GSWKey_SessionID[GSWebNamingConv]];
|
||||
[_associations removeObjectForKey:GSWKey_QuestionMarkSessionID[GSWebNamingConv]];
|
||||
}
|
||||
}
|
||||
else if (_value != nil)
|
||||
|
||||
if ([tempQueryAssociations count] > 0)
|
||||
{
|
||||
if ([_value isValueConstant])
|
||||
_sessionIDQueryAssociations = [tempQueryAssociations retain];
|
||||
}
|
||||
else
|
||||
{
|
||||
DESTROY(_sessionIDQueryAssociations);
|
||||
}
|
||||
|
||||
GSWAssignAndRemoveAssociation(&_file,_associations,imageMapFileName__Key);
|
||||
|
||||
if (!WOStrictFlag)
|
||||
{
|
||||
GSWAssignAndRemoveAssociation(&_imageMapString,_associations,imageMapString__Key);
|
||||
GSWAssignAndRemoveAssociation(&_imageMapRegions,_associations,imageMapRegions__Key);
|
||||
};
|
||||
|
||||
GSWAssignAndRemoveAssociation(&_action,_associations,action__Key);
|
||||
GSWAssignAndRemoveAssociation(&_href,_associations,href__Key);
|
||||
GSWAssignAndRemoveAssociation(&_src,_associations,src__Key);
|
||||
GSWAssignAndRemoveAssociation(&_xAssoc,_associations,x__Key);
|
||||
GSWAssignAndRemoveAssociation(&_yAssoc,_associations,y__Key);
|
||||
GSWAssignAndRemoveAssociation(&_target,_associations,target__Key);
|
||||
GSWAssignAndRemoveAssociation(&_filename,_associations,filename__Key);
|
||||
GSWAssignAndRemoveAssociation(&_framework,_associations,framework__Key);
|
||||
GSWAssignAndRemoveAssociation(&_data,_associations,data__Key);
|
||||
GSWAssignAndRemoveAssociation(&_mimeType,_associations,mimeType__Key);
|
||||
GSWAssignAndRemoveAssociation(&_key,_associations,key__Key);
|
||||
GSWAssignAndRemoveAssociation(&_border,_associations,border__Key);
|
||||
if (_border==nil)
|
||||
ASSIGN(_border,static_defaultBorderAssociation);
|
||||
|
||||
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: 'value' must not be constant.",
|
||||
format:@"%s: If 'action' is specified, 'directActionName', 'actionClass', and 'href' must be nil.",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
if (_src != nil)
|
||||
if ([_action isValueConstant])
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: If 'value' is specified, 'data', 'filename', and 'src' must be nil.",
|
||||
__PRETTY_FUNCTION__];
|
||||
format:@"%s: 'action' must not be a constant.",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
}
|
||||
else if (_src == nil)
|
||||
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: One of 'filename', 'src', 'data', or 'value' must be specified.",
|
||||
__PRETTY_FUNCTION__];
|
||||
format:@"%s: Either a component action or a direct action or 'href' must be specified.",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
}
|
||||
|
||||
if (_xAssoc != nil && _yAssoc != nil)
|
||||
{
|
||||
if (![_xAssoc isValueSettable] || ![_yAssoc isValueSettable])
|
||||
|
||||
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' can not be constants.",
|
||||
__PRETTY_FUNCTION__];
|
||||
format:@"%s: 'x' and 'y' must both be specified or both be nil.",
|
||||
__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;
|
||||
};
|
||||
|
||||
|
@ -315,6 +290,7 @@ static GSWAssociation * static_defaultBorderAssociation = nil;
|
|||
(void*)self];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(GSWAssociation*)hitTestX:(int)x
|
||||
y:(int)y
|
||||
inRegions:(NSArray*)regions
|
||||
|
@ -341,20 +317,18 @@ static GSWAssociation * static_defaultBorderAssociation = nil;
|
|||
-(id <GSWActionResults>)invokeActionForRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
NSObject <GSWActionResults> * results = nil;
|
||||
NSString* senderID=nil;
|
||||
NSString* elementID=nil;
|
||||
BOOL disabledInContext=NO;
|
||||
BOOL isInForm=NO;
|
||||
BOOL XYValues=NO;
|
||||
BOOL thisOne=NO;
|
||||
GSWComponent* component=nil;
|
||||
NSInteger x=0;
|
||||
NSInteger y=0;
|
||||
NSObject <GSWActionResults> * results = nil;
|
||||
GSWComponent* component=GSWContext_component(aContext);
|
||||
NSString* senderID=nil;
|
||||
NSString* elementID=nil;
|
||||
BOOL disabledInContext=NO;
|
||||
BOOL isInForm=NO;
|
||||
BOOL XYValues=NO;
|
||||
BOOL thisOne=NO;
|
||||
NSInteger x=0;
|
||||
NSInteger y=0;
|
||||
|
||||
|
||||
component=GSWContext_component(aContext);
|
||||
|
||||
GSWContext_appendZeroElementIDComponent(aContext);
|
||||
|
||||
senderID=GSWContext_senderID(aContext);
|
||||
|
@ -418,22 +392,22 @@ static GSWAssociation * static_defaultBorderAssociation = nil;
|
|||
GSWAssociation* actionAssociation=nil;
|
||||
NSArray* regions=nil;
|
||||
if (_file)
|
||||
{
|
||||
id imageMapFileNameValue=[_file valueInComponent:component];
|
||||
NSString* 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.");
|
||||
};
|
||||
}
|
||||
{
|
||||
id imageMapFileNameValue=[_file valueInComponent:component];
|
||||
NSString* 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];
|
||||
|
@ -518,6 +492,7 @@ static GSWAssociation * static_defaultBorderAssociation = nil;
|
|||
return results;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)appendAttributesToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -532,137 +507,156 @@ static GSWAssociation * static_defaultBorderAssociation = nil;
|
|||
[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 (![self disabledInComponent:component])
|
||||
{
|
||||
if ([context isInForm])
|
||||
GSWResponse_appendContentAsciiString(response, @" type=image");
|
||||
else
|
||||
{
|
||||
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 {
|
||||
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)
|
||||
{
|
||||
BOOL secure = (_secure != nil ? [_secure boolValueInComponent:component] : NO);
|
||||
GSWContext_appendZeroElementIDComponent(context);
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
@"src",
|
||||
[context _componentActionURLIsSecure:secure],
|
||||
NO);
|
||||
GSWContext_deleteLastElementIDComponent(context);
|
||||
}
|
||||
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 _appendDataURLAttributeToResponse: 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
|
||||
{
|
||||
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);
|
||||
|
||||
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;
|
||||
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
|
||||
{
|
||||
BOOL secure = (_secure != nil ? [_secure boolValueInComponent:component] : NO);
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, @"href",
|
||||
[context _componentActionURLIsSecure:secure],
|
||||
NO);
|
||||
|
||||
}
|
||||
[self appendConstantAttributesToResponse:response
|
||||
inContext:context];
|
||||
|
||||
[super _appendNameAttributeToResponse:response
|
||||
inContext:context];
|
||||
|
||||
[self appendNonURLAttributesToResponse:response
|
||||
inContext:context];
|
||||
|
||||
if (_target != nil)
|
||||
{
|
||||
NSString* targetValue = NSStringWithObject([_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];
|
||||
inContext:context];
|
||||
|
||||
[super _appendNameAttributeToResponse:response
|
||||
inContext:context];
|
||||
|
||||
inContext:context];
|
||||
|
||||
[self appendNonURLAttributesToResponse:response
|
||||
inContext:context];
|
||||
|
||||
inContext:context];
|
||||
|
||||
[self appendAttributesToResponse:response
|
||||
inContext:context];
|
||||
inContext:context];
|
||||
GSWResponse_appendContentCharacter(response,'>');
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendCGIActionURLToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -677,11 +671,13 @@ static GSWAssociation * static_defaultBorderAssociation = nil;
|
|||
otherQueryAssociations: _sessionIDQueryAssociations
|
||||
inContext: context];
|
||||
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, @"href", [context _directActionURLForActionNamed:actionStr
|
||||
queryDictionary:queryDictionary
|
||||
isSecure:[self secureInContext:context]
|
||||
port:0
|
||||
escapeQueryDictionary:YES], NO);
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
@"href",
|
||||
[context _directActionURLForActionNamed:actionStr
|
||||
queryDictionary:queryDictionary
|
||||
isSecure:[self secureInContext:context]
|
||||
port:0
|
||||
escapeQueryDictionary:YES], NO);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3668,5 +3668,10 @@ to another instance **/
|
|||
// or [GSWDynamicURLString stringWithString:url]
|
||||
// instead.
|
||||
|
||||
// Returns GSWExtensions or WOExtensions
|
||||
- (NSString*)frameworkNameGSWExtensions
|
||||
{
|
||||
return GSWFramework_extensions[GSWebNamingConv];
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
#include "GSWKeyValueAssociation.h"
|
||||
#include "GSWConstantValueAssociation.h"
|
||||
#include "GSWBindingNameAssociation.h"
|
||||
|
@ -880,9 +881,10 @@ static Class NSStringClass = Nil;
|
|||
int i=0;
|
||||
id value=nil;
|
||||
id newValue=nil;
|
||||
IMP oaiIMP=NULL;
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
value=[self objectAtIndex:i];
|
||||
value=GSWeb_objectAtIndexWithImpPtr(self,&oaiIMP,i);
|
||||
if ([value isKindOfClass:[NSString class]])
|
||||
{
|
||||
newValue=[GSWAssociation associationFromString:value];
|
||||
|
|
|
@ -35,14 +35,6 @@
|
|||
|
||||
//====================================================================
|
||||
@interface GSWBody: GSWHTMLURLValuedElement
|
||||
-(id)initWithName:(NSString*)name
|
||||
associations:(NSDictionary*)associations
|
||||
contentElements:(NSMutableArray*)elements;
|
||||
-(void)dealloc;
|
||||
-(NSString*)valueAttributeName;
|
||||
-(NSString*)urlAttributeName;
|
||||
-(NSString*)elementName;
|
||||
-(NSString*)description;
|
||||
@end
|
||||
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ RCS_ID("$Id$")
|
|||
associations:(NSDictionary*)associations
|
||||
contentElements:(NSMutableArray*)elements
|
||||
{
|
||||
if ((self=[super initWithName:name
|
||||
if ((self=[super initWithName:@"body"
|
||||
associations:associations
|
||||
contentElements:elements]))
|
||||
{
|
||||
|
@ -49,12 +49,6 @@ RCS_ID("$Id$")
|
|||
return self;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)valueAttributeName
|
||||
{
|
||||
|
@ -67,12 +61,6 @@ RCS_ID("$Id$")
|
|||
return @"background";
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)elementName
|
||||
{
|
||||
return @"body";
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)description
|
||||
{
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
|
||||
/**
|
||||
Bindings
|
||||
|
@ -65,87 +66,48 @@ Bindings
|
|||
//====================================================================
|
||||
@implementation GSWBrowser
|
||||
|
||||
static SEL objectAtIndexSEL = NULL;
|
||||
static SEL setValueInComponentSEL = NULL;
|
||||
static SEL valueInComponentSEL = NULL;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GSWBrowser class])
|
||||
{
|
||||
objectAtIndexSEL=@selector(objectAtIndex:);
|
||||
setValueInComponentSEL=@selector(setValue:inComponent:);
|
||||
valueInComponentSEL=@selector(valueInComponent:);
|
||||
};
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
self = [super initWithName:@"select" associations:associations template: template];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
if ((self = [super initWithName:@"select"
|
||||
associations:associations
|
||||
template: template]))
|
||||
{
|
||||
_loggedSlow = NO;
|
||||
|
||||
_loggedSlow = NO;
|
||||
GSWAssignAndRemoveAssociation(&_list,_associations,list__Key);
|
||||
GSWAssignAndRemoveAssociation(&_item,_associations,item__Key);
|
||||
GSWAssignAndRemoveAssociation(&_displayString,_associations,displayString__Key);
|
||||
GSWAssignAndRemoveAssociation(&_selections,_associations,selections__Key);
|
||||
GSWAssignAndRemoveAssociation(&_multiple,_associations,multiple__Key);
|
||||
GSWAssignAndRemoveAssociation(&_size,_associations,size__Key);
|
||||
GSWAssignAndRemoveAssociation(&_selectedValues,_associations,selectedValues__Key);
|
||||
GSWAssignAndRemoveAssociation(&_escapeHTML,_associations,escapeHTML__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(_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]))) {
|
||||
|
||||
[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__];
|
||||
}
|
||||
if (_list == nil || ((_value != nil || _displayString != nil) &&
|
||||
((_item == nil || ![_item isValueSettable]))) ||
|
||||
(_selections != nil && ![_selections 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 (_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(_displayString);
|
||||
|
@ -158,6 +120,7 @@ static SEL valueInComponentSEL = NULL;
|
|||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id) description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%s %p list:%@ item:%@ displayString:%@ selections:%@ selectedValues:%@ multiple:%@ size:%@ escapeHTML:%@>",
|
||||
|
@ -169,6 +132,7 @@ static SEL valueInComponentSEL = NULL;
|
|||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
/*
|
||||
On WO it looks like that when value is not bound:
|
||||
|
||||
|
@ -185,112 +149,134 @@ static SEL valueInComponentSEL = NULL;
|
|||
-(void) appendChildrenToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
NSArray * valueArray = nil;
|
||||
NSArray * selectionsArray = nil;
|
||||
int listCount = 0;
|
||||
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) {
|
||||
NSArray* list = nil;
|
||||
NSUInteger listCount = 0;
|
||||
NSArray* selections = nil;
|
||||
int i = 0;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
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]];
|
||||
}
|
||||
}
|
||||
|
||||
if (_selections != nil) {
|
||||
selectionsArray = [_selections valueInComponent:component];
|
||||
} else {
|
||||
if (_selectedValues != nil) {
|
||||
selectionsArray = [_selectedValues valueInComponent:component];
|
||||
list = [_list valueInComponent:component];
|
||||
if (list != nil)
|
||||
{
|
||||
if ([list isKindOfClass:[NSArray class]])
|
||||
{
|
||||
listCount = [list count];
|
||||
}
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
|
||||
__PRETTY_FUNCTION__, [list class]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
if (_selections != nil)
|
||||
selections = [_selections valueInComponent:component];
|
||||
else if (_selectedValues != nil)
|
||||
selections = [_selectedValues valueInComponent:component];
|
||||
|
||||
for (i = 0; i < listCount; i++)
|
||||
{
|
||||
NSString* displayString=nil;
|
||||
id item = nil;
|
||||
BOOL isSelected=NO;
|
||||
NSString* valueString = nil;
|
||||
id value = nil;
|
||||
|
||||
if (list != nil)
|
||||
item = GSWeb_objectAtIndexWithImpPtr(list,&oaiIMP,i);
|
||||
|
||||
} 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>");
|
||||
}
|
||||
if (_displayString != nil
|
||||
|| _value != nil)
|
||||
{
|
||||
[_item setValue:item
|
||||
inComponent:component];
|
||||
|
||||
if (_displayString != nil)
|
||||
{
|
||||
displayString = [_displayString valueInComponent:component];
|
||||
if (displayString!=nil)
|
||||
{
|
||||
if (_value != nil)
|
||||
{
|
||||
value = [_value valueInComponent:component];
|
||||
valueString = NSStringWithObject(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = displayString;
|
||||
valueString = NSStringWithObject(displayString);
|
||||
}
|
||||
displayString=NSStringWithObject(displayString);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = [_value valueInComponent:component];
|
||||
if (value != nil)
|
||||
{
|
||||
valueString=NSStringWithObject(value);
|
||||
displayString = valueString;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = item;
|
||||
valueString = NSStringWithObject(item);
|
||||
displayString = valueString;
|
||||
}
|
||||
|
||||
GSWResponse_appendContentAsciiString(response,@"\n<option");
|
||||
if (_selections != nil)
|
||||
{
|
||||
if (item
|
||||
&& selections)
|
||||
isSelected = [selections containsObject:item];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_value != nil)
|
||||
{
|
||||
if (item
|
||||
&& selections)
|
||||
isSelected = [selections containsObject:value];
|
||||
}
|
||||
else
|
||||
isSelected = [selections containsObject:GSWIntToNSString(i)];
|
||||
}
|
||||
if (isSelected)
|
||||
GSWResponse_appendContentAsciiString(response,@" selected");
|
||||
|
||||
if (_value != nil)
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, value__Key, valueString, YES);
|
||||
else
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, value__Key, GSWIntToNSString(i), NO);
|
||||
|
||||
GSWResponse_appendContentCharacter(response,'>');
|
||||
if (doEscape)
|
||||
GSWResponse_appendContentHTMLConvertString(response, displayString);
|
||||
else
|
||||
GSWResponse_appendContentString(response, displayString);
|
||||
|
||||
GSWResponse_appendContentAsciiString(response,@"</option>");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendValueAttributeToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
//Do nothing
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendAttributesToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -301,139 +287,191 @@ static SEL valueInComponentSEL = NULL;
|
|||
[super appendAttributesToResponse:response
|
||||
inContext:context];
|
||||
|
||||
if (_size != nil)
|
||||
{
|
||||
sizeValue = [_size valueInComponent:component];
|
||||
sizeInt = [sizeValue intValue];
|
||||
sizeValue = GSWIntToNSString(sizeInt);
|
||||
}
|
||||
|
||||
if (_size != nil) {
|
||||
sizeValue = [_size valueInComponent:component];
|
||||
sizeInt = [sizeValue intValue];
|
||||
sizeValue = GSWIntToNSString(sizeInt);
|
||||
}
|
||||
|
||||
if (_size == nil || sizeValue == nil || (sizeInt < 2)) {
|
||||
sizeValue = GSWIntToNSString(5);
|
||||
}
|
||||
if (_size == nil
|
||||
|| sizeValue == nil
|
||||
|| sizeInt < 2)
|
||||
{
|
||||
sizeValue = GSWIntToNSString(5);
|
||||
}
|
||||
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, size__Key, sizeValue, NO);
|
||||
|
||||
if (_multiple != nil && ([_multiple boolValueInComponent:component])) {
|
||||
GSWResponse_appendContentCharacter(response,' ');
|
||||
GSWResponse_appendContentAsciiString(response,@"multiple");
|
||||
}
|
||||
if (_multiple != nil
|
||||
&& [_multiple boolValueInComponent:component])
|
||||
{
|
||||
GSWResponse_appendContentAsciiString(response,@" multiple");
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (void)_slowTakeValuesFromRequest:(GSWRequest*) request
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
|
||||
if ((_selections != nil) && (![self disabledInComponent:component]) && ([context _wasFormSubmitted])) {
|
||||
if (_selections != nil
|
||||
&& ![self disabledInComponent:component]
|
||||
&& [context _wasFormSubmitted])
|
||||
{
|
||||
NSString * ctxName = [self nameInContext:context];
|
||||
NSArray * formValues = [request formValuesForKey: ctxName];
|
||||
NSArray * selections = nil;
|
||||
|
||||
if (formValues != nil)
|
||||
{
|
||||
NSUInteger formValuesCount = [formValues count];
|
||||
|
||||
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 (formValuesCount>0)
|
||||
{
|
||||
if (_list != nil)
|
||||
{
|
||||
NSArray* list = [_list valueInComponent:component];
|
||||
if ([list isKindOfClass:[NSArray class]] == NO)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
|
||||
__PRETTY_FUNCTION__, [list class]];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSUInteger listCount = [list count];
|
||||
int i=0;
|
||||
IMP oaiIMP=NULL;
|
||||
BOOL multiple = NO;
|
||||
if (_multiple != nil)
|
||||
multiple = [_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
|
||||
}
|
||||
for (i = 0; i < listCount; i++)
|
||||
{
|
||||
id value = nil;
|
||||
id item = GSWeb_objectAtIndexWithImpPtr(list,&oaiIMP,i);
|
||||
|
||||
[_item setValue:item
|
||||
inComponent: component];
|
||||
|
||||
value = [_value valueInComponent:component];
|
||||
if (value != nil)
|
||||
{
|
||||
if ([formValues containsObject:NSStringWithObject(value)])
|
||||
{
|
||||
if (selections==nil)
|
||||
selections=[NSMutableArray array];
|
||||
[(NSMutableArray*)selections addObject:item];
|
||||
if (!multiple)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"%s: 'value' evaluated to null in component %@, %@",
|
||||
__PRETTY_FUNCTION__, component, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (selections==nil)
|
||||
selections = [NSArray array];
|
||||
[_selections setValue:selections
|
||||
inComponent: component];
|
||||
}
|
||||
[_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;
|
||||
|
||||
if (formValues != nil) {
|
||||
count = [formValues count];
|
||||
mutArray = [NSMutableArray arrayWithCapacity:count];
|
||||
if (_selections != nil
|
||||
&& ![self disabledInComponent:component]
|
||||
&& [context _wasFormSubmitted])
|
||||
{
|
||||
NSString * ctxName = [self nameInContext:context];
|
||||
NSArray * formValues = [request formValuesForKey: ctxName];
|
||||
NSArray * selections = nil;
|
||||
|
||||
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];
|
||||
if (listValue != nil) {
|
||||
id valueValue = [listValue objectAtIndex:k];
|
||||
[mutArray addObject:valueValue];
|
||||
}
|
||||
}
|
||||
|
||||
[_selections setValue:mutArray inComponent: component];
|
||||
if (formValues != nil)
|
||||
{
|
||||
int formValuesCount = [formValues count];
|
||||
if (formValuesCount>0)
|
||||
{
|
||||
NSArray* list = nil;
|
||||
|
||||
if (_list != nil)
|
||||
{
|
||||
list = [_list valueInComponent:component];
|
||||
if ([list isKindOfClass:[NSArray class]] == NO)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
|
||||
__PRETTY_FUNCTION__, [list class]];
|
||||
}
|
||||
else
|
||||
{
|
||||
IMP formValues_oaiIMP=NULL;
|
||||
IMP list_oaiIMP=NULL;
|
||||
int i=0;
|
||||
BOOL multiple = NO;
|
||||
if (_multiple != nil)
|
||||
multiple = [_multiple boolValueInComponent:component];
|
||||
|
||||
for (i = 0; i < formValuesCount; i++)
|
||||
{
|
||||
NSString* formValue = GSWeb_objectAtIndexWithImpPtr(formValues,&formValues_oaiIMP,i);
|
||||
int intFormValue = [formValue intValue];
|
||||
if (list != nil)
|
||||
{
|
||||
id item = GSWeb_objectAtIndexWithImpPtr(list,&list_oaiIMP,intFormValue);
|
||||
if (selections==nil)
|
||||
selections=[NSMutableArray array];
|
||||
[(NSMutableArray*)selections addObject:item];
|
||||
}
|
||||
if (!multiple)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selections==nil)
|
||||
selections = [NSArray array];
|
||||
|
||||
[_selections setValue:selections
|
||||
inComponent: component];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(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;
|
||||
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];
|
||||
}
|
||||
[self _slowTakeValuesFromRequest:request inContext:context];
|
||||
} else {
|
||||
[self _fastTakeValuesFromRequest:request inContext:context];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -70,32 +70,29 @@ static Class standardClass = Nil;
|
|||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
self = [super initWithName:@"input" associations:associations template: nil];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
if ((self = [super initWithName:@"input"
|
||||
associations:associations
|
||||
template: nil]))
|
||||
{
|
||||
GSWAssignAndRemoveAssociation(&_checked,_associations,checked__Key);
|
||||
GSWAssignAndRemoveAssociation(&_selection,_associations,selection__Key);
|
||||
|
||||
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__];
|
||||
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";
|
||||
|
@ -117,79 +114,96 @@ static Class standardClass = Nil;
|
|||
(void*)self];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)takeValuesFromRequest:(GSWRequest*) request
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
id valueValue = nil;
|
||||
id selectionValue = nil;
|
||||
BOOL isChecked = NO;
|
||||
|
||||
if ((![self disabledInComponent: component]) && ([context _wasFormSubmitted])) {
|
||||
NSString * nameCtx = [self nameInContext:context];
|
||||
if (nameCtx != nil) {
|
||||
NSArray* formValues = [request formValuesForKey: nameCtx];
|
||||
if (![self disabledInComponent: component]
|
||||
&& [context _wasFormSubmitted])
|
||||
{
|
||||
NSString * nameCtx = [self nameInContext:context];
|
||||
if (nameCtx != nil)
|
||||
{
|
||||
BOOL isChecked = NO;
|
||||
id value = nil;
|
||||
NSArray* formValues = [request formValuesForKey: nameCtx];
|
||||
|
||||
if (_value != nil) {
|
||||
valueValue = [_value valueInComponent:component];
|
||||
} else {
|
||||
valueValue = [context elementID];
|
||||
}
|
||||
isChecked = [formValues containsObject: NSStringWithObject(valueValue)];
|
||||
if (_value != nil)
|
||||
value = [_value valueInComponent:component];
|
||||
else
|
||||
value = [context elementID];
|
||||
|
||||
isChecked = [formValues containsObject: NSStringWithObject(value)];
|
||||
|
||||
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];
|
||||
|
||||
}
|
||||
if (_value != nil
|
||||
&& _selection != nil)
|
||||
{
|
||||
if (isChecked)
|
||||
{
|
||||
[_selection setValue: value
|
||||
inComponent: component];
|
||||
}
|
||||
else
|
||||
{
|
||||
id selection = [_selection valueInComponent:component];
|
||||
if (selection != nil)
|
||||
{
|
||||
[_selection setValue: nil
|
||||
inComponent: component];;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_checked != nil)
|
||||
{
|
||||
[_checked setValue: (isChecked ? GSWNumberYes : GSWNumberNo)
|
||||
inComponent: component];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendCloseTagToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
// nothing!
|
||||
// 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");
|
||||
}
|
||||
if (_value != nil)
|
||||
{
|
||||
id value = [_value valueInComponent:component];
|
||||
if (value != nil
|
||||
&& _selection != nil)
|
||||
{
|
||||
id selection = [_selection valueInComponent:component];
|
||||
|
||||
if (selection != nil
|
||||
&& [selection isEqual: value])
|
||||
{
|
||||
GSWResponse_appendContentAsciiString(response,@" checked");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // _value == nil
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, value__Key, [context elementID], NO);
|
||||
}
|
||||
if (_checked != nil
|
||||
&& [_checked boolValueInComponent:component])
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
|
||||
/**
|
||||
Bindings
|
||||
|
@ -81,11 +82,14 @@ static Class standardClass = Nil;
|
|||
};
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
if ((self = [super initWithName:aName associations:associations template: template]))
|
||||
if ((self = [super initWithName:aName
|
||||
associations:associations
|
||||
template: template]))
|
||||
{
|
||||
_loggedSlow = NO;
|
||||
|
||||
|
@ -94,13 +98,13 @@ static Class standardClass = Nil;
|
|||
GSWAssignAndRemoveAssociation(&_index,_associations,index__Key);
|
||||
GSWAssignAndRemoveAssociation(&_selections,_associations,selections__Key);
|
||||
GSWAssignAndRemoveAssociation(&_prefix,_associations,prefix__Key);
|
||||
GSWAssignAndRemoveAssociation(&_prefix,_associations,prefix__Key);
|
||||
GSWAssignAndRemoveAssociation(&_suffix,_associations,suffix__Key);
|
||||
GSWAssignAndRemoveAssociation(&_escapeHTML,_associations,escapeHTML__Key);
|
||||
GSWAssignAndRemoveAssociation(&_displayString,_associations,displayString__Key);
|
||||
|
||||
if (GSWAssignAndRemoveAssociation(&_displayString,_associations,displayString__Key)==nil)
|
||||
if (_displayString==nil)
|
||||
{
|
||||
GSWAssignAndRemoveAssociation(&_displayString,_associations,value__Key);
|
||||
ASSIGN(_displayString, _value);
|
||||
_defaultEscapeHTML = NO;
|
||||
}
|
||||
else
|
||||
|
@ -120,6 +124,7 @@ static Class standardClass = Nil;
|
|||
return self;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)dealloc
|
||||
{
|
||||
DESTROY(_list);
|
||||
|
@ -133,6 +138,7 @@ static Class standardClass = Nil;
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id) description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%s %p list:%@ item:%@ index:%@ selections:%@ prefix:%@ suffix:%@ displayString:%@ escapeHTML:%@>",
|
||||
|
@ -142,12 +148,13 @@ static Class standardClass = Nil;
|
|||
_selections, _prefix, _suffix, _displayString, _escapeHTML];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)elementName
|
||||
{
|
||||
return @"input";
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)_slowTakeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
|
@ -161,53 +168,54 @@ static Class standardClass = Nil;
|
|||
NSArray * formValues = [request formValuesForKey: ctxName];
|
||||
int formValuesCount = [formValues count];
|
||||
|
||||
if (formValuesCount==0)
|
||||
selections = [NSArray array];
|
||||
else
|
||||
if (formValuesCount>0)
|
||||
{
|
||||
NSArray* listValue = [_list valueInComponent:component];
|
||||
int listCount = 0;
|
||||
int i=0;
|
||||
NSArray* list = [_list valueInComponent:component];
|
||||
|
||||
if ([listValue isKindOfClass:[NSArray class]] == NO)
|
||||
if ([list isKindOfClass:[NSArray class]] == NO)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
|
||||
__PRETTY_FUNCTION__, [listValue class]];
|
||||
__PRETTY_FUNCTION__, [list class]];
|
||||
}
|
||||
|
||||
listCount = [listValue count];
|
||||
|
||||
selections = [NSMutableArray arrayWithCapacity:formValuesCount];
|
||||
|
||||
for (i = 0; i < listCount; i++)
|
||||
else
|
||||
{
|
||||
id item = [listValue objectAtIndex:i];
|
||||
id value = nil;
|
||||
|
||||
[_item setValue: item
|
||||
inComponent: component];
|
||||
|
||||
value = [_value valueInComponent:component];
|
||||
if (value != nil)
|
||||
NSUInteger listCount = [list count];
|
||||
int i=0;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
selections = [NSMutableArray arrayWithCapacity:formValuesCount];
|
||||
|
||||
for (i = 0; i < listCount; i++)
|
||||
{
|
||||
if ([formValues containsObject:NSStringWithObject(value)])
|
||||
[(NSMutableArray*)selections addObject:item];
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"%s 'value' evaluated to nil in component %@.\nUnable to select item %@",
|
||||
__PRETTY_FUNCTION__, self, value);
|
||||
id item = GSWeb_objectAtIndexWithImpPtr(list,&oaiIMP,i);
|
||||
id value = nil;
|
||||
|
||||
[_item setValue: item
|
||||
inComponent: component];
|
||||
|
||||
value = [_value valueInComponent:component];
|
||||
if (value != nil)
|
||||
{
|
||||
if ([formValues containsObject:NSStringWithObject(value)])
|
||||
[(NSMutableArray*)selections addObject:item];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"%s 'value' evaluated to nil in component %@.\nUnable to select item %@",
|
||||
__PRETTY_FUNCTION__, self, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (selections==nil)
|
||||
selections = [NSArray array];
|
||||
[_selections setValue: selections
|
||||
inComponent: component];
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)_fastTakeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
|
@ -221,167 +229,172 @@ static Class standardClass = Nil;
|
|||
NSString * ctxName = [self nameInContext:context];
|
||||
NSArray * formValues = [request formValuesForKey: ctxName];
|
||||
int formValuesCount = [formValues count];
|
||||
if (formValuesCount==0)
|
||||
if (formValuesCount>0)
|
||||
{
|
||||
selections = [NSArray array];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSArray* listValue = [_list valueInComponent:component];
|
||||
int listCount = 0;
|
||||
int i = 0;
|
||||
|
||||
if ([listValue isKindOfClass:[NSArray class]] == NO)
|
||||
NSArray* list = [_list valueInComponent:component];
|
||||
if ([list isKindOfClass:[NSArray class]] == NO)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
|
||||
__PRETTY_FUNCTION__, [listValue class]];
|
||||
__PRETTY_FUNCTION__, [list class]];
|
||||
}
|
||||
|
||||
listCount = [listValue count];
|
||||
|
||||
for (i = 0; i < listCount; i++)
|
||||
else
|
||||
{
|
||||
int itemIndex = [NSStringWithObject([formValues objectAtIndex:i]) intValue];
|
||||
[(NSMutableArray*)selections addObject:[listValue objectAtIndex:itemIndex]];
|
||||
int i=0;
|
||||
IMP formValues_oaiIMP=NULL;
|
||||
IMP list_oaiIMP=NULL;
|
||||
for (i = 0; i < formValuesCount; i++)
|
||||
{
|
||||
int itemIndex = [NSStringWithObject(GSWeb_objectAtIndexWithImpPtr(formValues,&formValues_oaiIMP,i)) intValue];
|
||||
[(NSMutableArray*)selections addObject:GSWeb_objectAtIndexWithImpPtr(list,&list_oaiIMP,itemIndex)];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (selections==nil)
|
||||
selections = [NSArray array];
|
||||
[_selections setValue: selections
|
||||
inComponent: component];
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)appendToResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
id listValue = [_list valueInComponent:component];
|
||||
int listCount = 0;
|
||||
NSArray* list = [_list valueInComponent:component];
|
||||
|
||||
if ([listValue isKindOfClass:[NSArray class]] == NO)
|
||||
if ([list isKindOfClass:[NSArray class]] == NO)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
|
||||
__PRETTY_FUNCTION__, [listValue class]];
|
||||
__PRETTY_FUNCTION__, [list class]];
|
||||
}
|
||||
|
||||
listCount=[listValue count];
|
||||
if (listCount>0)
|
||||
else
|
||||
{
|
||||
NSString* ctxName = [self nameInContext:context];
|
||||
int i = 0;
|
||||
BOOL doEscape = NO;
|
||||
id selections = nil;
|
||||
|
||||
if (_escapeHTML==nil)
|
||||
doEscape=_defaultEscapeHTML;
|
||||
else
|
||||
doEscape=[_escapeHTML boolValueInComponent:component];
|
||||
|
||||
if (_selections!=nil)
|
||||
selections = [_selections valueInComponent:component];
|
||||
|
||||
for (i = 0; i < listCount; i++)
|
||||
NSUInteger listCount=[list count];
|
||||
if (listCount>0)
|
||||
{
|
||||
NSString * prefixStr = nil;
|
||||
NSString * suffixStr = nil;
|
||||
NSString * displayString = nil;
|
||||
id item = nil;
|
||||
id value = nil;
|
||||
|
||||
if (_prefix != nil)
|
||||
prefixStr = NSStringWithObject([_prefix valueInComponent:component]);
|
||||
|
||||
if (_suffix != nil)
|
||||
suffixStr = NSStringWithObject([_suffix valueInComponent:component]);
|
||||
|
||||
if (_index != nil)
|
||||
NSString* ctxName = [self nameInContext:context];
|
||||
int i = 0;
|
||||
BOOL doEscape = NO;
|
||||
id selections = nil;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
if (_escapeHTML==nil)
|
||||
doEscape=_defaultEscapeHTML;
|
||||
else
|
||||
doEscape=[_escapeHTML boolValueInComponent:component];
|
||||
|
||||
if (_selections!=nil)
|
||||
selections = [_selections valueInComponent:component];
|
||||
|
||||
for (i = 0; i < listCount; i++)
|
||||
{
|
||||
[_index setValue:GSWIntToNSString(i)
|
||||
inComponent:component];
|
||||
}
|
||||
|
||||
item = [listValue objectAtIndex:i];
|
||||
|
||||
if (_item != nil
|
||||
&& _displayString != nil)
|
||||
{
|
||||
id displayValue=nil;
|
||||
[_item setValue:item
|
||||
inComponent:component];
|
||||
|
||||
displayValue= [_displayString valueInComponent:component];
|
||||
|
||||
if (displayValue == nil)
|
||||
NSString * prefixStr = nil;
|
||||
NSString * suffixStr = nil;
|
||||
NSString * displayString = nil;
|
||||
id item = nil;
|
||||
id value = nil;
|
||||
|
||||
if (_prefix != nil)
|
||||
prefixStr = NSStringWithObject([_prefix valueInComponent:component]);
|
||||
|
||||
if (_suffix != nil)
|
||||
suffixStr = NSStringWithObject([_suffix valueInComponent:component]);
|
||||
|
||||
if (_index != nil)
|
||||
{
|
||||
displayString = NSStringWithObject(displayValue);
|
||||
NSLog(@"%s: 'displayString' evaluated to nil in component %@. Using %@",
|
||||
__PRETTY_FUNCTION__, component, displayString);
|
||||
[_index setValue:GSWIntToNSString(i)
|
||||
inComponent:component];
|
||||
}
|
||||
|
||||
item = GSWeb_objectAtIndexWithImpPtr(list,&oaiIMP,i);
|
||||
|
||||
if (_item != nil
|
||||
&& _displayString != nil)
|
||||
{
|
||||
id displayValue=nil;
|
||||
[_item setValue:item
|
||||
inComponent:component];
|
||||
|
||||
displayValue= [_displayString valueInComponent:component];
|
||||
|
||||
if (displayValue == nil)
|
||||
{
|
||||
displayString = NSStringWithObject(displayValue);
|
||||
NSLog(@"%s: 'displayString' evaluated to nil in component %@. Using %@",
|
||||
__PRETTY_FUNCTION__, component, displayString);
|
||||
}
|
||||
else
|
||||
{
|
||||
displayString = NSStringWithObject(displayValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
displayString = NSStringWithObject(item);
|
||||
|
||||
GSWResponse_appendContentAsciiString(response, @"<input name=\"");
|
||||
GSWResponse_appendContentString(response,ctxName);
|
||||
GSWResponse_appendContentAsciiString(response,@"\" type=checkbox value=\"");
|
||||
|
||||
if (_value != nil)
|
||||
{
|
||||
displayString = NSStringWithObject(displayValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
displayString = NSStringWithObject(item);
|
||||
|
||||
GSWResponse_appendContentAsciiString(response, @"<input name=\"");
|
||||
GSWResponse_appendContentString(response,ctxName);
|
||||
GSWResponse_appendContentAsciiString(response,@"\" type=checkbox value=\"");
|
||||
|
||||
if (_value != nil)
|
||||
{
|
||||
value = [_value valueInComponent:component];
|
||||
if (value != nil)
|
||||
{
|
||||
GSWResponse_appendContentHTMLConvertString(response, NSStringWithObject(value));
|
||||
value = [_value valueInComponent:component];
|
||||
if (value != nil)
|
||||
{
|
||||
GSWResponse_appendContentHTMLConvertString(response, NSStringWithObject(value));
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"%s: 'value' evaluated to nil in component %@. Using to index.",
|
||||
__PRETTY_FUNCTION__, self);
|
||||
}
|
||||
}
|
||||
if (value == nil)
|
||||
GSWResponse_appendContentAsciiString(response,GSWIntToNSString(i));
|
||||
|
||||
if ([selections containsObject:item])
|
||||
GSWResponse_appendContentAsciiString(response,@"\" checked>");
|
||||
else
|
||||
{
|
||||
NSLog(@"%s: 'value' evaluated to nil in component %@. Using to index.",
|
||||
__PRETTY_FUNCTION__, self);
|
||||
}
|
||||
}
|
||||
if (value == nil)
|
||||
GSWResponse_appendContentAsciiString(response,GSWIntToNSString(i));
|
||||
|
||||
if ([selections containsObject:item])
|
||||
GSWResponse_appendContentAsciiString(response,@"\" checked>");
|
||||
else
|
||||
GSWResponse_appendContentAsciiString(response,@"\">");
|
||||
|
||||
if (prefixStr != nil)
|
||||
GSWResponse_appendContentString(response,prefixStr);
|
||||
|
||||
if (doEscape)
|
||||
GSWResponse_appendContentHTMLConvertString(response,displayString);
|
||||
else
|
||||
GSWResponse_appendContentString(response,displayString);
|
||||
|
||||
if (suffixStr != nil)
|
||||
GSWResponse_appendContentString(response,suffixStr);
|
||||
} // for
|
||||
GSWResponse_appendContentAsciiString(response,@"\">");
|
||||
|
||||
if (prefixStr != nil)
|
||||
GSWResponse_appendContentString(response,prefixStr);
|
||||
|
||||
if (doEscape)
|
||||
GSWResponse_appendContentHTMLConvertString(response,displayString);
|
||||
else
|
||||
GSWResponse_appendContentString(response,displayString);
|
||||
|
||||
if (suffixStr != nil)
|
||||
GSWResponse_appendContentString(response,suffixStr);
|
||||
} // for
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(BOOL)appendStringAtRight:(id)_unkwnon
|
||||
withMapping:(char*)_mapping
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(BOOL)appendStringAtLeft:(id)_unkwnon
|
||||
withMapping:(char*)_mapping
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(BOOL)compactHTMLTags
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
|
|
|
@ -32,29 +32,18 @@
|
|||
#ifndef _GSWClientSideScript_h__
|
||||
#define _GSWClientSideScript_h__
|
||||
|
||||
//OK
|
||||
//====================================================================
|
||||
@interface GSWClientSideScript: GSWDynamicElement
|
||||
@interface GSWClientSideScript: GSWHTMLDynamicElement
|
||||
{
|
||||
GSWAssociation* _scriptFile;
|
||||
GSWAssociation* _scriptString;
|
||||
GSWAssociation* _scriptSource;
|
||||
GSWAssociation* _hideInComment;
|
||||
GSWAssociation* _language;
|
||||
NSDictionary* _otherAttributes;
|
||||
};
|
||||
|
||||
-(id)initWithName:(NSString*)name
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)templateElement;
|
||||
-(void)dealloc;
|
||||
-(void)setLanguage:(NSString*)language;
|
||||
|
||||
@end
|
||||
|
||||
//====================================================================
|
||||
@interface GSWClientSideScript (GSWClientSideScriptA)
|
||||
-(void)appendToResponse:(GSWResponse*)aResponse
|
||||
inContext:(GSWContext*)aContext;
|
||||
@end
|
||||
|
||||
#endif //GSWClientSideScript
|
||||
|
|
|
@ -56,36 +56,33 @@ static Class standardClass = Nil;
|
|||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)templateElement
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
|
||||
|
||||
[tmpAssociations removeObjectForKey:scriptFile__Key];
|
||||
[tmpAssociations removeObjectForKey:scriptString__Key];
|
||||
[tmpAssociations removeObjectForKey:scriptSource__Key];
|
||||
[tmpAssociations removeObjectForKey:hideInComment__Key];
|
||||
[tmpAssociations removeObjectForKey:language__Key];
|
||||
_otherAttributes=[NSDictionary dictionaryWithDictionary:tmpAssociations];
|
||||
RETAIN(_otherAttributes);
|
||||
if ((self=[super initWithName:aName
|
||||
if ((self=[super initWithName:@"SCRIPT"
|
||||
associations:nil
|
||||
template:templateElement]))
|
||||
template:nil]))
|
||||
{
|
||||
_scriptFile = [[associations objectForKey:scriptFile__Key
|
||||
withDefaultObject:[_scriptFile autorelease]] retain];
|
||||
|
||||
_scriptString = [[associations objectForKey:scriptString__Key
|
||||
withDefaultObject:[_scriptString autorelease]] retain];
|
||||
|
||||
_scriptSource = [[associations objectForKey:scriptSource__Key
|
||||
withDefaultObject:[_scriptSource autorelease]] retain];
|
||||
|
||||
_hideInComment = [[associations objectForKey:hideInComment__Key
|
||||
withDefaultObject:[_hideInComment autorelease]] retain];
|
||||
|
||||
_language = [[associations objectForKey:language__Key
|
||||
withDefaultObject:[_language autorelease]] retain];
|
||||
|
||||
GSWAssignAndRemoveAssociation(&_scriptFile,_associations,scriptFile__Key);
|
||||
GSWAssignAndRemoveAssociation(&_scriptString,_associations,scriptString__Key);
|
||||
GSWAssignAndRemoveAssociation(&_scriptSource,_associations,scriptSource__Key);
|
||||
GSWAssignAndRemoveAssociation(&_language,_associations,language__Key);
|
||||
GSWAssignAndRemoveAssociation(&_hideInComment,_associations,hideInComment__Key);
|
||||
if (_scriptFile == nil
|
||||
&& _scriptString == nil
|
||||
&& _scriptSource == nil)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: one of 'scriptFile' or 'scriptString' or 'scriptSource' attributes must be specified.",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
else if (_scriptFile != nil
|
||||
&& _scriptString != nil
|
||||
&& _scriptFile != nil)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Only one of 'scriptFile' or 'scriptString' or 'scriptSource' attributes can specified.",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
};
|
||||
return self;
|
||||
};
|
||||
|
@ -98,141 +95,140 @@ static Class standardClass = Nil;
|
|||
DESTROY(_scriptSource);
|
||||
DESTROY(_hideInComment);
|
||||
DESTROY(_language);
|
||||
DESTROY(_otherAttributes);
|
||||
[super dealloc];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
@end
|
||||
|
||||
//====================================================================
|
||||
@implementation GSWClientSideScript (GSWClientSideScriptA)
|
||||
-(void)appendToResponse:(GSWResponse*)aResponse
|
||||
inContext:(GSWContext*)aContext
|
||||
-(void)setLanguage:(NSString*)language
|
||||
{
|
||||
GSWComponent* component=nil;
|
||||
BOOL hideInCommentValue=NO;
|
||||
id languageValue=nil;
|
||||
id scriptValue=nil;
|
||||
|
||||
GSWStartElement(aContext);
|
||||
GSWSaveAppendToResponseElementID(aContext);
|
||||
component=GSWContext_component(aContext);
|
||||
[super appendToResponse:aResponse
|
||||
inContext:aContext];
|
||||
//hideInCommentValue=[_hideInComment valueInComponent:component];
|
||||
hideInCommentValue=GSWDynamicElement_evaluateValueInContext(self,standardClass,
|
||||
standardEvaluateConditionInContextIMP,
|
||||
_hideInComment,aContext);
|
||||
GSWResponse_appendContentAsciiString(aResponse,@"<SCRIPT language=");
|
||||
languageValue=[_language valueInComponent:component];
|
||||
|
||||
GSWResponse_appendContentHTMLAttributeValue(aResponse,languageValue);
|
||||
if ([_otherAttributes count]>0)
|
||||
{
|
||||
NSEnumerator* enumerator = [_otherAttributes keyEnumerator];
|
||||
id key;
|
||||
id value;
|
||||
while ((key = [enumerator nextObject]))
|
||||
{
|
||||
value=[_otherAttributes objectForKey:key];
|
||||
GSWResponse_appendContentCharacter(aResponse,' ');
|
||||
GSWResponse_appendContentString(aResponse,key);
|
||||
if (value)
|
||||
{
|
||||
GSWResponse_appendContentCharacter(aResponse,'=');
|
||||
GSWResponse_appendContentHTMLAttributeValue(aResponse,value);
|
||||
};
|
||||
};
|
||||
};
|
||||
if (_scriptSource)
|
||||
{
|
||||
scriptValue=[_scriptSource valueInComponent:component];
|
||||
if (scriptValue)
|
||||
{
|
||||
GSWResponse_appendContentString(aResponse,@" src=\"");
|
||||
GSWResponse_appendContentString(aResponse,scriptValue);
|
||||
GSWResponse_appendContentCharacter(aResponse,'"');
|
||||
};
|
||||
}
|
||||
GSWResponse_appendContentCharacter(aResponse,'>');
|
||||
if (_scriptString || _scriptFile)
|
||||
{
|
||||
GSWResponse_appendContentCharacter(aResponse,'\n');
|
||||
if (hideInCommentValue)
|
||||
GSWResponse_appendContentAsciiString(aResponse,@"<!-- GNUstepWeb ClientScript\n");
|
||||
|
||||
if (_scriptString)
|
||||
{
|
||||
scriptValue=[_scriptString valueInComponent:component];
|
||||
if (scriptValue)
|
||||
GSWResponse_appendContentString(aResponse,scriptValue);
|
||||
else
|
||||
{
|
||||
//TODO
|
||||
};
|
||||
}
|
||||
else if (_scriptFile)
|
||||
{
|
||||
NSString* scriptFileName=[_scriptFile valueInComponent:component];
|
||||
if (scriptFileName)
|
||||
{
|
||||
NSError * error = nil;
|
||||
GSWResourceManager * resourceManager = nil;
|
||||
NSString * path = nil;
|
||||
|
||||
resourceManager=[GSWApp resourceManager];
|
||||
path=[resourceManager pathForResourceNamed:scriptFileName
|
||||
inFramework:nil
|
||||
languages:[aContext languages]];
|
||||
if (path)
|
||||
{
|
||||
NSString * scriptValue = nil;
|
||||
NSStringEncoding usedEncoding;
|
||||
|
||||
scriptValue = [NSString stringWithContentsOfFile:path
|
||||
usedEncoding:&usedEncoding
|
||||
error:&error];
|
||||
if (scriptValue)
|
||||
{
|
||||
GSWResponse_appendContentString(aResponse,scriptValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSException* exception=nil;
|
||||
exception=[NSException exceptionWithName:NSInvalidArgumentException
|
||||
reason:[NSString stringWithFormat:
|
||||
@"Can't open script file '%@' - %@",
|
||||
scriptFileName, error]
|
||||
userInfo:nil];
|
||||
[exception raise];
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
NSException* exception=nil;
|
||||
exception=[NSException exceptionWithName:NSInvalidArgumentException
|
||||
reason:[NSString stringWithFormat:
|
||||
@"No script file name"]
|
||||
userInfo:nil];
|
||||
[exception raise];
|
||||
};
|
||||
};
|
||||
|
||||
GSWResponse_appendContentCharacter(aResponse,'\n');
|
||||
if (hideInCommentValue)
|
||||
GSWResponse_appendContentAsciiString(aResponse,@"//-->\n");
|
||||
};
|
||||
GSWResponse_appendContentAsciiString(aResponse,@"</SCRIPT>");
|
||||
GSWStopElement(aContext);
|
||||
};
|
||||
if (language!=nil)
|
||||
ASSIGN(_language,([GSWAssociation associationWithValue:language]));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)appendAttributesToResponse:(GSWResponse *) aResponse
|
||||
inContext:(GSWContext*) aContext
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(aContext);
|
||||
|
||||
NSString* language=[_language valueInComponent:component];
|
||||
if (language == nil)
|
||||
{
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s: language binding evaluated to nil",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
GSWResponse_appendContentAsciiString(aResponse,@" language=");
|
||||
GSWResponse_appendContentHTMLAttributeValue(aResponse,NSStringWithObject(language));
|
||||
|
||||
if (_scriptSource != nil)
|
||||
{
|
||||
NSString* url=NSStringWithObject([_scriptSource valueInComponent:component]);
|
||||
if (url != nil)
|
||||
{
|
||||
if ([url isRelativeURL])
|
||||
{
|
||||
if ([url isFragmentURL])
|
||||
{
|
||||
NSLog(@"%s warning: relative fragment URL %@",__PRETTY_FUNCTION__,url);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString* tmp = [aContext _urlForResourceNamed:url
|
||||
inFramework:nil];//and 3rd param: YES
|
||||
if (tmp != nil)
|
||||
url = tmp;
|
||||
else
|
||||
url = [[[component baseURL]
|
||||
stringByAppendingString:@"/"]
|
||||
stringByAppendingString:tmp];
|
||||
}
|
||||
}
|
||||
if (url != nil)
|
||||
{
|
||||
GSWResponse_appendContentAsciiString(aResponse,@" src=\"");
|
||||
GSWResponse_appendContentString(aResponse,url);
|
||||
GSWResponse_appendContentCharacter(aResponse,'"');
|
||||
}
|
||||
}
|
||||
}
|
||||
[super appendAttributesToResponse:aResponse
|
||||
inContext:aContext];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)appendChildrenToResponse:(GSWResponse *) aResponse
|
||||
inContext:(GSWContext*) aContext
|
||||
{
|
||||
if(_scriptSource == nil)
|
||||
{
|
||||
NSString* scriptContent = nil;
|
||||
BOOL hideInComment = NO;
|
||||
GSWComponent * component = GSWContext_component(aContext);
|
||||
|
||||
if (_hideInComment != nil
|
||||
&& [_hideInComment boolValueInComponent:component])
|
||||
hideInComment = YES;
|
||||
|
||||
if (hideInComment)
|
||||
GSWResponse_appendContentAsciiString(aResponse,@"<!-- Dynamic client side script from GNUstepWeb");
|
||||
|
||||
GSWResponse_appendContentCharacter(aResponse,'\n');
|
||||
|
||||
if(_scriptFile != nil)
|
||||
{
|
||||
NSString* scriptFile = NSStringWithObject([_scriptFile valueInComponent:component]);
|
||||
if (scriptFile == nil)
|
||||
{
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s: scriptFile evaluate to nil",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString* scriptPath = [[GSWApp resourceManager] pathForResourceNamed:scriptFile
|
||||
inFramework:nil
|
||||
languages:[aContext languages]];
|
||||
if (scriptPath == nil)
|
||||
{
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s: cannot find script file '%@'",
|
||||
__PRETTY_FUNCTION__,scriptFile];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSStringEncoding usedEncoding;
|
||||
NSString* error=nil;
|
||||
NSString* scriptContent = [NSString stringWithContentsOfFile:scriptPath
|
||||
usedEncoding:&usedEncoding
|
||||
error:&error];
|
||||
if (scriptContent == nil)
|
||||
{
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s: cannot load script at path '%@': %@",
|
||||
__PRETTY_FUNCTION__,scriptPath,error];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_scriptString != nil)
|
||||
{
|
||||
scriptContent = NSStringWithObject([_scriptString valueInComponent:component]);
|
||||
if(scriptContent == nil)
|
||||
{
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s: scriptString evaluate to nil",
|
||||
__PRETTY_FUNCTION__];
|
||||
};
|
||||
}
|
||||
|
||||
GSWResponse_appendContentString(aResponse,scriptContent);
|
||||
GSWResponse_appendContentCharacter(aResponse,'\n');
|
||||
|
||||
if(hideInComment)
|
||||
GSWResponse_appendContentAsciiString(aResponse,@"//-->\n");
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -68,20 +68,21 @@ static Class standardClass = Nil;
|
|||
associations:(NSDictionary*)someAssociations
|
||||
template:(GSWElement*)templateElement
|
||||
{
|
||||
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__];
|
||||
}
|
||||
if ((self = [super initWithName:nil
|
||||
associations:nil
|
||||
template: templateElement]))
|
||||
{
|
||||
// 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;
|
||||
};
|
||||
|
||||
|
@ -95,6 +96,7 @@ static Class standardClass = Nil;
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%s %p condition: %@ negate: %@>",
|
||||
|
@ -103,53 +105,60 @@ static Class standardClass = Nil;
|
|||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
BOOL conVal = [_condition boolValueInComponent:component];
|
||||
BOOL doNegate = NO;
|
||||
if (_negate != nil) {
|
||||
if (_negate != nil)
|
||||
doNegate = [_negate boolValueInComponent:component];
|
||||
}
|
||||
if ((conVal && !doNegate) || (!conVal && doNegate)) {
|
||||
[super takeValuesFromRequest:request inContext:context];
|
||||
}
|
||||
|
||||
if ((conVal && !doNegate)
|
||||
|| (!conVal && doNegate))
|
||||
{
|
||||
[super takeValuesFromRequest:request
|
||||
inContext:context];
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id <GSWActionResults>)invokeActionForRequest:(GSWRequest*) request
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
id <GSWActionResults> result=nil;
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
BOOL conVal = [_condition boolValueInComponent:component];
|
||||
BOOL doNegate = NO;
|
||||
if (_negate != nil) {
|
||||
if (_negate != nil)
|
||||
doNegate = [_negate boolValueInComponent:component];
|
||||
}
|
||||
if ((conVal && !doNegate) || (!conVal && doNegate)) {
|
||||
return [super invokeActionForRequest:request inContext:context];
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ((conVal && !doNegate)
|
||||
|| (!conVal && doNegate))
|
||||
{
|
||||
result=[super invokeActionForRequest:request
|
||||
inContext:context];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)appendToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
BOOL conVal = [_condition boolValueInComponent:component];
|
||||
BOOL doNegate = NO;
|
||||
if (_negate != nil) {
|
||||
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 ) -->");
|
||||
if ((conVal && !doNegate)
|
||||
|| (!conVal && doNegate))
|
||||
{
|
||||
[super appendChildrenToResponse:response
|
||||
inContext:context];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -212,7 +212,7 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext);
|
|||
pathQueryDictionary:(NSDictionary*)pathQueryDictionary
|
||||
isSecure:(BOOL)isSecure;
|
||||
-(GSWDynamicURLString*)componentActionURL;
|
||||
-(GSWDynamicURLString*)componentActionURLIsSecure:(BOOL)isSecure;
|
||||
-(GSWDynamicURLString*)_componentActionURLIsSecure:(BOOL)isSecure;
|
||||
|
||||
-(GSWDynamicURLString*)urlWithURLPrefix:(NSString*)urlPrefix
|
||||
requestHandlerKey:(NSString*)requestHandlerKey
|
||||
|
@ -326,7 +326,8 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext);
|
|||
pathQueryDictionary:(NSDictionary*)pathQueryDictionary
|
||||
url:(id)url;
|
||||
|
||||
-(GSWDynamicURLString*) _componentActionURL;
|
||||
-(GSWDynamicURLString*) componentActionURL;
|
||||
-(GSWDynamicURLString*) _componentActionURLIsSecure:(BOOL)isSecure;
|
||||
|
||||
/** Returns array of languages
|
||||
First try session languages, if none, try self language
|
||||
|
|
|
@ -869,60 +869,64 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
|
|||
//--------------------------------------------------------------------
|
||||
-(GSWDynamicURLString*)componentActionURL
|
||||
{
|
||||
GSWDynamicURLString* url=nil;
|
||||
|
||||
url=[self componentActionURLIsSecure:[[self request]isSecure]];
|
||||
|
||||
return url;
|
||||
return [self _componentActionURLIsSecure:[[self request]isSecure]];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(GSWDynamicURLString*)componentActionURLIsSecure:(BOOL)isSecure
|
||||
-(GSWDynamicURLString*) _componentActionURLIsSecure:(BOOL)isSecure
|
||||
{
|
||||
BOOL storesIDsInURLs=NO;
|
||||
GSWDynamicURLString* url=nil;
|
||||
GSWSession* session=nil;
|
||||
NSString* elementID=nil;
|
||||
NSString* componentRequestHandlerKey=nil;
|
||||
NSString* requestHandlerKey=nil;
|
||||
NSString* requestHandlerPath=nil;
|
||||
|
||||
session=[self session]; //OK
|
||||
|
||||
elementID=[self elementID];
|
||||
|
||||
componentRequestHandlerKey=[GSWApplication componentRequestHandlerKey];
|
||||
GSWSession * session = [self session];
|
||||
NSString * contextID = [self contextID];
|
||||
NSString * elementID = [self elementID];
|
||||
NSString * actionURL = nil;
|
||||
|
||||
requestHandlerKey=componentRequestHandlerKey;
|
||||
storesIDsInURLs=[session storesIDsInURLs];
|
||||
|
||||
if (storesIDsInURLs)
|
||||
if ([GSWApp pageCacheSize] == 0)
|
||||
{
|
||||
NSString* sessionID=[_session sessionID];
|
||||
// requestHandlerPath as sessionID/_contextID.elementID
|
||||
if (sessionID)
|
||||
{
|
||||
requestHandlerPath=[[sessionID stringByAppendingString:@"/"]
|
||||
stringByAppendingString:GSWContext_contextAndElementID(self)];
|
||||
}
|
||||
if ([session storesIDsInURLs])
|
||||
{
|
||||
actionURL=GSWJoinedStrings(7,
|
||||
[[self page] name],
|
||||
@"/",
|
||||
[session sessionID],
|
||||
@"/",
|
||||
contextID,
|
||||
@".",
|
||||
elementID);
|
||||
}
|
||||
else
|
||||
{
|
||||
requestHandlerPath=[@"/" stringByAppendingString:GSWContext_contextAndElementID(self)];
|
||||
};
|
||||
{
|
||||
actionURL=GSWJoinedStrings(5,
|
||||
[[self page] name],
|
||||
@"/",
|
||||
contextID,
|
||||
@".",
|
||||
elementID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// requestHandlerPath as /_contextID.elementID
|
||||
requestHandlerPath=[@"/" stringByAppendingString:GSWContext_contextAndElementID(self)];
|
||||
};
|
||||
|
||||
url=[self urlWithRequestHandlerKey:requestHandlerKey
|
||||
path:requestHandlerPath
|
||||
queryString:nil
|
||||
isSecure:isSecure];
|
||||
|
||||
return url;
|
||||
};
|
||||
if ([session storesIDsInURLs])
|
||||
{
|
||||
actionURL=GSWJoinedStrings(5,
|
||||
[session sessionID],
|
||||
@"/",
|
||||
contextID,
|
||||
@".",
|
||||
elementID);
|
||||
}
|
||||
else
|
||||
{
|
||||
actionURL=GSWJoinedStrings(3,
|
||||
contextID,
|
||||
@".",
|
||||
elementID);
|
||||
}
|
||||
}
|
||||
return [self urlWithRequestHandlerKey:[[GSWApp class] componentRequestHandlerKey]
|
||||
path: actionURL
|
||||
queryString: nil
|
||||
isSecure:isSecure];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(GSWDynamicURLString*)urlWithURLPrefix:(NSString*)urlPrefix
|
||||
|
@ -1195,17 +1199,8 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
|
|||
//--------------------------------------------------------------------
|
||||
-(void)_putAwakeComponentsToSleep
|
||||
{
|
||||
int i=0;
|
||||
int count=0;
|
||||
GSWComponent* component=nil;
|
||||
|
||||
count=[_awakePageComponents count];
|
||||
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
component=[_awakePageComponents objectAtIndex:i];
|
||||
[component sleepInContext:self];
|
||||
};
|
||||
[_awakePageComponents makeObjectsPerformSelector:@selector(sleepInContext:)
|
||||
withObject:self];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -1399,11 +1394,12 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
|
|||
NSArray* keys=[[pathQueryDictionary allKeys]sortedArrayUsingSelector:@selector(compare:)];
|
||||
int count=[keys count];
|
||||
int i=0;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
// append each key/value pair as /key=value
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
id key = [keys objectAtIndex:i];
|
||||
id key = GSWeb_objectAtIndexWithImpPtr(keys,&oaiIMP,i);
|
||||
id value = [pathQueryDictionary valueForKey:key];
|
||||
if (!value)
|
||||
value=[NSString string];
|
||||
|
@ -1454,47 +1450,6 @@ GSWEB_EXPORT BOOL GSWContext_isSenderIDSearchOver(GSWContext* aContext)
|
|||
url:anURL];
|
||||
}
|
||||
|
||||
-(GSWDynamicURLString*) _componentActionURL
|
||||
{
|
||||
GSWSession * session = [self session];
|
||||
NSString * s = [self contextID];
|
||||
NSString * s1 = [self elementID];
|
||||
NSMutableString * actionURL = [NSMutableString string];
|
||||
|
||||
if ([GSWApp pageCacheSize] == 0) {
|
||||
if ([session storesIDsInURLs]) {
|
||||
[actionURL appendString:[[self page] name]];
|
||||
[actionURL appendString:@"/"];
|
||||
[actionURL appendString:[session sessionID]];
|
||||
[actionURL appendString:@"/"];
|
||||
[actionURL appendString:s];
|
||||
[actionURL appendString:@"."];
|
||||
[actionURL appendString:s1];
|
||||
} else {
|
||||
[actionURL appendString:[[self page] name]];
|
||||
[actionURL appendString:@"/"];
|
||||
[actionURL appendString:s];
|
||||
[actionURL appendString:@"."];
|
||||
[actionURL appendString:s1];
|
||||
}
|
||||
} else {
|
||||
if ([session storesIDsInURLs]) {
|
||||
[actionURL appendString:[session sessionID]];
|
||||
[actionURL appendString:@"/"];
|
||||
[actionURL appendString:s];
|
||||
[actionURL appendString:@"."];
|
||||
[actionURL appendString:s1];
|
||||
} else {
|
||||
[actionURL appendString:s];
|
||||
[actionURL appendString:@"."];
|
||||
[actionURL appendString:s1];
|
||||
}
|
||||
}
|
||||
return [self urlWithRequestHandlerKey:[[GSWApp class] componentRequestHandlerKey]
|
||||
path: actionURL
|
||||
queryString: nil];
|
||||
|
||||
}
|
||||
|
||||
|
||||
// new
|
||||
|
@ -1819,37 +1774,38 @@ If none, try request languages
|
|||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _stripSessionIDFromURL
|
||||
{
|
||||
NSString * handlerPath = [[self _url] requestHandlerPath];
|
||||
if ((!handlerPath) || ([handlerPath isEqual:@""])) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSRange range;
|
||||
unsigned handlerPathlength;
|
||||
|
||||
range = [handlerPath rangeOfString:[GSWApp sessionIdKey]];
|
||||
|
||||
if (range.location > 0) {
|
||||
NSRange endRange;
|
||||
NSRange totalRange;
|
||||
|
||||
handlerPathlength = [handlerPath length];
|
||||
|
||||
totalRange = NSMakeRange(range.location, handlerPathlength-range.location);
|
||||
|
||||
endRange = [handlerPath rangeOfString:@"&"
|
||||
options:0
|
||||
range:totalRange];
|
||||
|
||||
if(endRange.location == NSNotFound) {
|
||||
[[self _url] setRequestHandlerPath: [handlerPath substringWithRange:NSMakeRange(0, range.location)]];
|
||||
} else {
|
||||
[[self _url] setRequestHandlerPath:[[handlerPath substringWithRange:NSMakeRange(0, range.location)]
|
||||
stringByAppendingString:[handlerPath substringWithRange:NSMakeRange(range.location + 1, handlerPathlength)]]];
|
||||
if ([handlerPath length]>0)
|
||||
{
|
||||
NSRange range = [handlerPath rangeOfString:[GSWApp sessionIdKey]];
|
||||
if (range.location > 0)
|
||||
{
|
||||
NSUInteger handlerPathLength = [handlerPath length];
|
||||
NSRange totalRange = NSMakeRange(range.location,
|
||||
handlerPathLength-range.location);
|
||||
NSRange endRange = [handlerPath rangeOfString:@"&"
|
||||
options:0
|
||||
range:totalRange];
|
||||
|
||||
if(endRange.location == NSNotFound)
|
||||
{
|
||||
[[self _url] setRequestHandlerPath:
|
||||
[handlerPath substringWithRange:NSMakeRange(0,
|
||||
range.location)]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[[self _url] setRequestHandlerPath:
|
||||
[[handlerPath substringWithRange:NSMakeRange(0, range.location)]
|
||||
stringByAppendingString:[handlerPath
|
||||
substringWithRange:NSMakeRange(range.location + 1,
|
||||
handlerPathLength)]]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1866,70 +1822,81 @@ If none, try request languages
|
|||
queryDictionary:(NSDictionary*) queryDictionary
|
||||
otherQueryDictionary:(NSDictionary*) otherQueryDictionary
|
||||
{
|
||||
NSMutableDictionary * newQueryDictionary;
|
||||
NSMutableDictionary * newQueryDictionary = nil;
|
||||
NSString * sessionId = nil;
|
||||
GSWSession * sess = nil;
|
||||
if (queryDictionary != nil) {
|
||||
|
||||
if (queryDictionary != nil)
|
||||
newQueryDictionary = [[queryDictionary mutableCopy] autorelease];
|
||||
} else {
|
||||
else
|
||||
newQueryDictionary = [NSMutableDictionary dictionary];
|
||||
}
|
||||
|
||||
if ([self hasSession])
|
||||
{
|
||||
sess = [self session];
|
||||
if (![sess isTerminating]
|
||||
&& [sess storesIDsInURLs])
|
||||
{
|
||||
sessionId = [sess sessionID];
|
||||
}
|
||||
}
|
||||
else if ([self _sessionIDInURL])
|
||||
sessionId = _requestSessionID;
|
||||
|
||||
if ([self hasSession]) {
|
||||
sess = [self session];
|
||||
if ((![sess isTerminating]) && [sess storesIDsInURLs]) {
|
||||
sessionId = [sess sessionID];
|
||||
if (sessionId != nil
|
||||
&& GSWIsBoolNumberYes([newQueryDictionary sessionID]))
|
||||
{
|
||||
[newQueryDictionary setObject:sessionId
|
||||
forKey:[GSWApp sessionIdKey]];
|
||||
}
|
||||
} else {
|
||||
if ([self _sessionIDInURL]) {
|
||||
sessionId = _requestSessionID;
|
||||
}
|
||||
}
|
||||
|
||||
if ((sessionId != nil) && ([[newQueryDictionary sessionID] boolValue])) {
|
||||
[newQueryDictionary setObject:sessionId
|
||||
forKey:[GSWApp sessionIdKey]];
|
||||
} else {
|
||||
if ([newQueryDictionary count] > 0) {
|
||||
[newQueryDictionary removeObjectForKey:[GSWApp sessionIdKey]];
|
||||
[newQueryDictionary removeObjectForKey:@"wosid"];
|
||||
}
|
||||
}
|
||||
if (otherQueryDictionary != nil) {
|
||||
NSEnumerator * keyEnumerator = [otherQueryDictionary keyEnumerator];
|
||||
NSString * aKey = nil;
|
||||
|
||||
while ((aKey = [keyEnumerator nextObject])) {
|
||||
id aValue = [otherQueryDictionary objectForKey:aKey];
|
||||
|
||||
if (([aKey isEqual:[GSWApp sessionIdKey]]) || ([aKey isEqual:@"wosid"])) {
|
||||
// CHECKME!
|
||||
if ([aValue boolValue] == NO) {
|
||||
[newQueryDictionary removeObjectForKey:aKey];
|
||||
}
|
||||
} else {
|
||||
[newQueryDictionary setObject:aValue forKey:aKey];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
sessionId = [newQueryDictionary objectForKey:[GSWApp sessionIdKey]];
|
||||
|
||||
if (sessionId) {
|
||||
NSRange range;
|
||||
NSRange range2;
|
||||
|
||||
range = [aRequestHandlerPath rangeOfString:sessionId];
|
||||
range2 = [aRequestHandlerPath rangeOfString:[GSWApp sessionIdKey]];
|
||||
|
||||
if ((range.location != NSNotFound) || (range.location != NSNotFound))
|
||||
else if ([newQueryDictionary count] > 0)
|
||||
{
|
||||
[newQueryDictionary removeObjectForKey:[GSWApp sessionIdKey]];
|
||||
[newQueryDictionary removeObjectForKey:@"wosid"];
|
||||
[newQueryDictionary removeObjectForKey:GSWKey_SessionID[GSWebNamingConv]];
|
||||
}
|
||||
} else {
|
||||
|
||||
if (otherQueryDictionary != nil)
|
||||
{
|
||||
NSEnumerator * keyEnumerator = [otherQueryDictionary keyEnumerator];
|
||||
NSString * aKey = nil;
|
||||
|
||||
while ((aKey = [keyEnumerator nextObject]))
|
||||
{
|
||||
id aValue = [otherQueryDictionary objectForKey:aKey];
|
||||
|
||||
if ([aKey isEqual:[GSWApp sessionIdKey]]
|
||||
|| [aKey isEqual:GSWKey_SessionID[GSWebNamingConv]])
|
||||
{
|
||||
if (GSWIsBoolNumberNo(aValue))
|
||||
[newQueryDictionary removeObjectForKey:aKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
[newQueryDictionary setObject:aValue
|
||||
forKey:aKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
sessionId = [newQueryDictionary objectForKey:[GSWApp sessionIdKey]];
|
||||
|
||||
if (sessionId)
|
||||
{
|
||||
NSRange range;
|
||||
NSRange range2;
|
||||
|
||||
range = [aRequestHandlerPath rangeOfString:sessionId];
|
||||
range2 = [aRequestHandlerPath rangeOfString:[GSWApp sessionIdKey]];
|
||||
|
||||
if (range.location != NSNotFound
|
||||
|| range2.location != NSNotFound)
|
||||
{
|
||||
[newQueryDictionary removeObjectForKey:[GSWApp sessionIdKey]];
|
||||
[newQueryDictionary removeObjectForKey:@"wosid"];
|
||||
}
|
||||
}
|
||||
else
|
||||
[self _stripSessionIDFromURL];
|
||||
}
|
||||
|
||||
return newQueryDictionary;
|
||||
}
|
||||
|
||||
|
@ -2043,12 +2010,7 @@ If none, try request languages
|
|||
//--------------------------------------------------------------------
|
||||
-(NSString*)url
|
||||
{
|
||||
//OK
|
||||
GSWDynamicURLString* componentActionURL=nil;
|
||||
|
||||
componentActionURL=[self componentActionURL];
|
||||
|
||||
return (NSString*)componentActionURL;
|
||||
return [self componentActionURL];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -2097,6 +2059,7 @@ If none, try request languages
|
|||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSString*) _urlForResourceNamed: (NSString*)aName
|
||||
inFramework: (NSString*)frameworkName
|
||||
{
|
||||
|
@ -2106,31 +2069,34 @@ If none, try request languages
|
|||
request: _request];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (BOOL) secureRequest
|
||||
{
|
||||
BOOL isSecure = NO;
|
||||
|
||||
if (_request != nil) {
|
||||
if (_request != nil)
|
||||
isSecure = [_request isSecure];
|
||||
}
|
||||
|
||||
return isSecure;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (BOOL) secureMode
|
||||
{
|
||||
if (_secureMode == -2) {
|
||||
if (_secureMode == -2)
|
||||
return [self secureRequest];
|
||||
}
|
||||
return ((_secureMode == YES));
|
||||
else
|
||||
return (_secureMode == YES);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (void) setSecureMode:(BOOL) value
|
||||
{
|
||||
_secureMode = (int) value;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (GSWDynamicURLString*) relativeURLWithRequestHandlerKey:(NSString*) requestHandlerKey
|
||||
path:(NSString*) requestHandlerPath
|
||||
queryString:(NSString*) queryString
|
||||
|
@ -2146,6 +2112,7 @@ If none, try request languages
|
|||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (GSWDynamicURLString*) _urlWithRequestHandlerKey:(NSString*) requestHandlerKey
|
||||
requestHandlerPath:(NSString*) aRequestHandlerPath
|
||||
queryString:(NSString*) aQueryString
|
||||
|
@ -2154,22 +2121,28 @@ If none, try request languages
|
|||
{
|
||||
GSWDynamicURLString * url = nil;
|
||||
|
||||
if (_generateCompleteURLs || ((_request != nil) && (isSecure != [_request isSecure]))) {
|
||||
url = [self completeURLWithRequestHandlerKey:requestHandlerKey
|
||||
path:aRequestHandlerPath
|
||||
queryString:aQueryString
|
||||
isSecure:isSecure
|
||||
port:somePort];
|
||||
} else {
|
||||
url = [self relativeURLWithRequestHandlerKey:requestHandlerKey
|
||||
path:aRequestHandlerPath
|
||||
queryString:aQueryString];
|
||||
|
||||
}
|
||||
if (_generateCompleteURLs
|
||||
|| (_request != nil
|
||||
&& isSecure != [_request isSecure]))
|
||||
{
|
||||
url = [self completeURLWithRequestHandlerKey:requestHandlerKey
|
||||
path:aRequestHandlerPath
|
||||
queryString:aQueryString
|
||||
isSecure:isSecure
|
||||
port:somePort];
|
||||
}
|
||||
else
|
||||
{
|
||||
url = [self relativeURLWithRequestHandlerKey:requestHandlerKey
|
||||
path:aRequestHandlerPath
|
||||
queryString:aQueryString];
|
||||
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (GSWDynamicURLString*) _urlWithRequestHandlerKey:(NSString*) requestHandlerKey
|
||||
requestHandlerPath:(NSString*) requestHandlerPath
|
||||
queryString:(NSString*) queryString
|
||||
|
@ -2182,15 +2155,15 @@ If none, try request languages
|
|||
port:0];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (WOMarkupType) markupType
|
||||
{
|
||||
if (_markupType == WOUndefinedMarkup)
|
||||
{
|
||||
GSWComponent* thePage = [self page];
|
||||
if (thePage) {
|
||||
_markupType = [thePage markupType];
|
||||
{
|
||||
GSWComponent* thePage = [self page];
|
||||
if (thePage)
|
||||
_markupType = [thePage markupType];
|
||||
}
|
||||
}
|
||||
return _markupType;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
{
|
||||
}
|
||||
|
||||
-(id)initWithRequest:(GSWRequest*)aRequest;
|
||||
-(id <GSWActionResults>)performActionNamed:(NSString*)actionName;
|
||||
-(id<GSWActionResults>)defaultAction;
|
||||
-(NSString*)sessionIDForRequest:(GSWRequest*)aRequest;
|
||||
|
|
|
@ -33,25 +33,11 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
|
||||
//====================================================================
|
||||
@implementation GSWDirectAction
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithRequest:(GSWRequest*)aRequest
|
||||
{
|
||||
if ((self=[super initWithRequest:aRequest]))
|
||||
{
|
||||
};
|
||||
return self;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id <GSWActionResults>)performActionNamed:(NSString*)actionName
|
||||
{
|
||||
|
@ -120,10 +106,11 @@ RCS_ID("$Id$")
|
|||
{
|
||||
NSUInteger count=[keyArray count];
|
||||
NSUInteger i=0;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
NSString* key=[keyArray objectAtIndex:i];
|
||||
NSString* key=GSWeb_objectAtIndexWithImpPtr(keyArray,&oaiIMP,i);
|
||||
NSArray* v=[request formValuesForKey:key];
|
||||
[self setValue:v
|
||||
forKey:key];
|
||||
|
@ -139,10 +126,11 @@ RCS_ID("$Id$")
|
|||
{
|
||||
NSUInteger count=[keyArray count];
|
||||
NSUInteger i=0;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
NSString* key=[keyArray objectAtIndex:i];
|
||||
NSString* key=GSWeb_objectAtIndexWithImpPtr(keyArray,&oaiIMP,i);
|
||||
id v=[request formValueForKey:key];
|
||||
[self setValue:v
|
||||
forKey:key];
|
||||
|
|
|
@ -54,20 +54,10 @@ SEL evaluateConditionInContextSEL = NULL;
|
|||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
id ourid = [super init];
|
||||
|
||||
if (ourid) {
|
||||
return ourid;
|
||||
}
|
||||
DESTROY(self);
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
if ((self=[super init]))
|
||||
{
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
@ -53,6 +53,12 @@
|
|||
|
||||
- (BOOL) hasChildrenElements;
|
||||
|
||||
-(void) takeChildrenValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)aContext;
|
||||
|
||||
-(id <GSWActionResults>) invokeChildrenActionForRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)aContext;
|
||||
|
||||
-(void) appendChildrenToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*)aContext;
|
||||
|
||||
|
|
|
@ -33,12 +33,14 @@
|
|||
RCS_ID("$Id: GSWDynamicGroup.m,v 1.17 2004/12/31 14:33:16 mguesdon Exp $")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
|
||||
static Class GSWHTMLBareStringClass = Nil;
|
||||
|
||||
//====================================================================
|
||||
@implementation GSWDynamicGroup
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GSWDynamicGroup class])
|
||||
|
@ -47,7 +49,7 @@ static Class GSWHTMLBareStringClass = Nil;
|
|||
};
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
+ (GSWDynamicGroup*) emptyGroup
|
||||
{
|
||||
GSWDynamicGroup * theGroup = [GSWDynamicGroup alloc];
|
||||
|
@ -60,78 +62,72 @@ static Class GSWHTMLBareStringClass = Nil;
|
|||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSMutableArray*) childrenElements
|
||||
{
|
||||
return _children;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (void) _initChildrenFromTemplate:(GSWElement*) element
|
||||
{
|
||||
NSMutableArray * array = nil;
|
||||
if (element) {
|
||||
|
||||
// [element isKindOfClass:[GSWDynamicGroup class]]
|
||||
if ([element isKindOfClass:[GSWHTMLStaticGroup class]]) {
|
||||
array = [(GSWDynamicGroup*) element childrenElements];
|
||||
//NSLog(@"%s element is %@ array is %@", __PRETTY_FUNCTION__, element, array);
|
||||
if (element)
|
||||
{
|
||||
// [element isKindOfClass:[GSWDynamicGroup class]]
|
||||
if ([element isKindOfClass:[GSWHTMLStaticGroup class]])
|
||||
{
|
||||
array = [(GSWDynamicGroup*) element childrenElements];
|
||||
//NSLog(@"%s element is %@ array is %@", __PRETTY_FUNCTION__, element, array);
|
||||
}
|
||||
// normally, this should be called only if the above isKindOfClass is NO.
|
||||
// BUT some elements seem be parsed wrong/different than in WO.
|
||||
if (array == nil)
|
||||
{
|
||||
array = [NSMutableArray array];
|
||||
[array addObject:element];
|
||||
}
|
||||
}
|
||||
// normally, this should be called only if the above isKindOfClass is NO.
|
||||
// BUT some elements seem be parsed wrong/different than in WO.
|
||||
if (array == nil) {
|
||||
array = [NSMutableArray array];
|
||||
[array addObject:element];
|
||||
}
|
||||
}
|
||||
DESTROY(_children);
|
||||
if ((array) && ([array count] > 0)) {
|
||||
if ([array count] > 0)
|
||||
ASSIGN(_children,array);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)name
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
id ourid = [super initWithName:nil
|
||||
associations:nil
|
||||
template:nil];
|
||||
|
||||
if (! ourid) {
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
[ourid _initChildrenFromTemplate:template];
|
||||
|
||||
return ourid;
|
||||
if ((self=[super initWithName:nil
|
||||
associations:nil
|
||||
template:nil]))
|
||||
{
|
||||
[self _initChildrenFromTemplate:template];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// YES it is called like that
|
||||
// initWithName:associations:contentElements
|
||||
// NOT initWithName: attributeAssociations: contentElements:
|
||||
|
||||
-(id)initWithName:(NSString*)name
|
||||
associations:(NSDictionary*)associations
|
||||
contentElements:(NSMutableArray*) children
|
||||
{
|
||||
id ourid = [super initWithName:nil
|
||||
associations:nil
|
||||
template:nil];
|
||||
|
||||
DESTROY(_children);
|
||||
|
||||
if (! ourid) {
|
||||
[self release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ((children) && ([children count] > 0)) {
|
||||
ASSIGN(_children, children);
|
||||
}
|
||||
return ourid;
|
||||
if ((self=[super initWithName:nil
|
||||
associations:nil
|
||||
template:nil]))
|
||||
{
|
||||
DESTROY(_children);
|
||||
if ([children count] > 0)
|
||||
ASSIGN(_children, children);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) dealloc
|
||||
{
|
||||
DESTROY(_children);
|
||||
|
@ -139,99 +135,118 @@ static Class GSWHTMLBareStringClass = Nil;
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) addChildElement:(id) element
|
||||
{
|
||||
if (_children == nil) {
|
||||
if (_children == nil)
|
||||
_children = [NSMutableArray new];
|
||||
}
|
||||
[_children addObject:element];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (BOOL) hasChildrenElements
|
||||
{
|
||||
return ((_children != nil) && ([_children count] > 0));
|
||||
return ([_children count] > 0 ? YES : NO);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) takeChildrenValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
if ([self hasChildrenElements]) {
|
||||
int i = [_children count];
|
||||
int j = 0;
|
||||
|
||||
[aContext appendZeroElementIDComponent];
|
||||
|
||||
for (; j < i; j++) {
|
||||
GSWElement * element = [_children objectAtIndex:j];
|
||||
[element takeValuesFromRequest: request
|
||||
inContext: aContext];
|
||||
[aContext incrementLastElementIDComponent];
|
||||
if ([self hasChildrenElements])
|
||||
{
|
||||
NSUInteger c = [_children count];
|
||||
int i = 0;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
GSWContext_appendZeroElementIDComponent(aContext);
|
||||
|
||||
for (i=0; i < c; i++)
|
||||
{
|
||||
GSWElement * element = GSWeb_objectAtIndexWithImpPtr(_children,&oaiIMP,i);
|
||||
if (i>0)
|
||||
GSWContext_incrementLastElementIDComponent(aContext);
|
||||
[element takeValuesFromRequest: request
|
||||
inContext: aContext];
|
||||
}
|
||||
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
}
|
||||
|
||||
[aContext deleteLastElementIDComponent];
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) takeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)aContext
|
||||
|
||||
{
|
||||
[self takeChildrenValuesFromRequest:request
|
||||
inContext:aContext];
|
||||
}
|
||||
|
||||
-(id <GSWActionResults>) invokeChildrenAction:(GSWRequest*)request
|
||||
inContext:(GSWContext*)aContext
|
||||
//--------------------------------------------------------------------
|
||||
-(id <GSWActionResults>) invokeChildrenActionForRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)aContext
|
||||
|
||||
{
|
||||
id actionresults = nil;
|
||||
if ([self hasChildrenElements]) {
|
||||
int kidsCount = [_children count];
|
||||
int j = 0;
|
||||
|
||||
[aContext appendZeroElementIDComponent];
|
||||
|
||||
for (; (j < kidsCount) && (actionresults == nil); j++) {
|
||||
GSWElement * element = [_children objectAtIndex:j];
|
||||
if ([element class] != GSWHTMLBareStringClass) {
|
||||
if ([self hasChildrenElements])
|
||||
{
|
||||
NSUInteger c = [_children count];
|
||||
int i = 0;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
actionresults = [element invokeActionForRequest: request
|
||||
inContext: aContext];
|
||||
}
|
||||
[aContext incrementLastElementIDComponent];
|
||||
}
|
||||
[aContext deleteLastElementIDComponent];
|
||||
GSWContext_appendZeroElementIDComponent(aContext);
|
||||
|
||||
for (i=0; i < c && actionresults == nil; i++)
|
||||
{
|
||||
GSWElement * element = GSWeb_objectAtIndexWithImpPtr(_children,&oaiIMP,i);
|
||||
if (i>0)
|
||||
GSWContext_incrementLastElementIDComponent(aContext);
|
||||
if ([element class] != GSWHTMLBareStringClass)
|
||||
{
|
||||
actionresults = [element invokeActionForRequest: request
|
||||
inContext: aContext];
|
||||
}
|
||||
}
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
}
|
||||
return actionresults;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id <GSWActionResults>) invokeActionForRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
return [self invokeChildrenAction:request
|
||||
inContext:aContext];
|
||||
return [self invokeChildrenActionForRequest:request
|
||||
inContext:aContext];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendChildrenToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
if ([self hasChildrenElements]) {
|
||||
int kidsCount = [_children count];
|
||||
int j = 0;
|
||||
if ([self hasChildrenElements])
|
||||
{
|
||||
NSUInteger c = [_children count];
|
||||
int i = 0;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
[aContext appendZeroElementIDComponent];
|
||||
|
||||
for (; j < kidsCount; j++) {
|
||||
GSWElement * element = [_children objectAtIndex:j];
|
||||
[element appendToResponse: response
|
||||
inContext: aContext];
|
||||
GSWContext_appendZeroElementIDComponent(aContext);
|
||||
|
||||
[aContext incrementLastElementIDComponent];
|
||||
for (i=0; i < c; i++)
|
||||
{
|
||||
GSWElement * element = GSWeb_objectAtIndexWithImpPtr(_children,&oaiIMP,i);
|
||||
if (i>0)
|
||||
GSWContext_incrementLastElementIDComponent(aContext);
|
||||
[element appendToResponse: response
|
||||
inContext: aContext];
|
||||
|
||||
}
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
}
|
||||
[aContext deleteLastElementIDComponent];
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
|
@ -239,6 +254,7 @@ static Class GSWHTMLBareStringClass = Nil;
|
|||
inContext: aContext];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%s %p children:%@>",
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
#include <GNUstepBase/NSObject+GNUstepBase.h>
|
||||
#include <GNUstepBase/NSString+GNUstepBase.h>
|
||||
|
||||
|
@ -550,9 +551,10 @@ static SEL appendStringSel = NULL;
|
|||
//NSDebugMLLog(@"low",@"prefix: components [%@]",components);
|
||||
components=[Left componentsSeparatedByString:@"/"];
|
||||
componentsCount=[components count];
|
||||
IMP oaiIMP=NULL;
|
||||
for(tmpIndex=index;!_prefix && tmpIndex<componentsCount;tmpIndex++)
|
||||
{
|
||||
NSString* tmp=[components objectAtIndex:tmpIndex];
|
||||
NSString* tmp=GSWeb_objectAtIndexWithImpPtr(components,&oaiIMP,tmpIndex);
|
||||
if ([tmp hasSuffix:GSWApplicationPSuffix[GSWNAMES_INDEX]]
|
||||
|| [tmp hasSuffix:GSWApplicationPSuffix[WONAMES_INDEX]])
|
||||
{
|
||||
|
@ -580,10 +582,10 @@ static SEL appendStringSel = NULL;
|
|||
{
|
||||
/*NSDebugMLLog(@"low",@"applicationName: components [%@]",
|
||||
[components subarrayWithRange:NSMakeRange(index,componentsCount-index)]);
|
||||
*/
|
||||
*/
|
||||
for(tmpIndex=index;!_applicationName && tmpIndex<componentsCount;tmpIndex++)
|
||||
{
|
||||
NSString* tmp=[components objectAtIndex:tmpIndex];
|
||||
NSString* tmp=GSWeb_objectAtIndexWithImpPtr(components,&oaiIMP,tmpIndex);
|
||||
NSString* appSuffix=nil;
|
||||
if ([tmp hasSuffix:GSWApplicationPSuffix[GSWNAMES_INDEX]])
|
||||
appSuffix=GSWApplicationPSuffix[GSWNAMES_INDEX];
|
||||
|
|
|
@ -41,65 +41,56 @@ RCS_ID("$Id$")
|
|||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
self = [super initWithName:@"input" associations:associations template: nil];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
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 ((self = [super initWithName:@"input"
|
||||
associations:associations
|
||||
template: nil]))
|
||||
{
|
||||
GSWAssignAndRemoveAssociation(&_data,_associations,data__Key);
|
||||
GSWAssignAndRemoveAssociation(&_filepath,_associations,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];
|
||||
}
|
||||
*/
|
||||
|
||||
ASSIGN(_multiple, [_associations objectForKey: multiple__Key]);
|
||||
if (_multiple != nil) {
|
||||
[_associations removeObjectForKey: multiple__Key];
|
||||
}
|
||||
GSWAssignAndRemoveAssociation(&_multiple,_associations,multiple__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__];
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -122,23 +113,28 @@ RCS_ID("$Id$")
|
|||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSString *) type
|
||||
{
|
||||
return @"file";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendValueAttributeToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
|
||||
if (_multiple != nil && ([_multiple boolValueInComponent:component])) {
|
||||
GSWResponse_appendContentCharacter(response,' ');
|
||||
GSWResponse_appendContentAsciiString(response,@"multiple");
|
||||
if (_multiple != nil)
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
if ([_multiple boolValueInComponent:component])
|
||||
{
|
||||
GSWResponse_appendContentCharacter(response,' ');
|
||||
GSWResponse_appendContentAsciiString(response,@"multiple");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendCloseTagToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -147,12 +143,13 @@ RCS_ID("$Id$")
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
-(id <GSWActionResults>)invokeActionForRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
//Bypass GSWInput
|
||||
return nil;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
/*
|
||||
"7.1.filename" = (
|
||||
"15072009(002).jpg",
|
||||
|
@ -166,68 +163,69 @@ RCS_ID("$Id$")
|
|||
-(void)takeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
if ((![self disabledInComponent: component]) && ([context _wasFormSubmitted]))
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
if (![self disabledInComponent: component]
|
||||
&& [context _wasFormSubmitted])
|
||||
{
|
||||
GSWComponent * component=nil;
|
||||
NSString * nameInContext=nil;
|
||||
NSArray * fileDatas=nil;
|
||||
NSString * fileNameFormValueName=nil;
|
||||
NSString * mimeValueName=nil;
|
||||
NSUInteger fileDatasCount=0;
|
||||
|
||||
NS_DURING
|
||||
NS_DURING
|
||||
{
|
||||
component=GSWContext_component(context);
|
||||
nameInContext=[self nameInContext:context];
|
||||
|
||||
fileNameFormValueName = [NSString stringWithFormat:@"%@.filename", nameInContext];
|
||||
mimeValueName = [NSString stringWithFormat:@"%@.%@",nameInContext, GSWHTTPHeader_ContentType];
|
||||
|
||||
fileDatas = [request formValuesForKey:nameInContext];
|
||||
|
||||
fileDatasCount = [fileDatas count];
|
||||
|
||||
if (fileDatasCount >= 1)
|
||||
GSWComponent* component=GSWContext_component(context);
|
||||
NSString* nameInContext=[self nameInContext:context];
|
||||
|
||||
NSString* fileNameFormValueName = [NSString stringWithFormat:@"%@.filename",
|
||||
nameInContext];
|
||||
NSString* mimeValueName = [NSString stringWithFormat:@"%@.%@",
|
||||
nameInContext,
|
||||
GSWHTTPHeader_ContentType];
|
||||
|
||||
NSArray* fileDatas = [request formValuesForKey:nameInContext];
|
||||
|
||||
NSUInteger fileDatasCount = [fileDatas count];
|
||||
|
||||
if (fileDatasCount >= 1)
|
||||
{
|
||||
NSArray * fileNameValue = [request formValuesForKey:fileNameFormValueName];
|
||||
NSArray * mimeValue = [request formValuesForKey:mimeValueName];;
|
||||
|
||||
if ([[fileNameValue objectAtIndex:0] length] == 0) {
|
||||
fileNameValue = nil;
|
||||
fileDatas = nil;
|
||||
mimeValue = nil;
|
||||
NSArray * fileNameValue = [request formValuesForKey:fileNameFormValueName];
|
||||
NSArray * mimeValue = [request formValuesForKey:mimeValueName];;
|
||||
|
||||
if ([[fileNameValue objectAtIndex:0] length] == 0)
|
||||
{
|
||||
fileNameValue = nil;
|
||||
fileDatas = nil;
|
||||
mimeValue = nil;
|
||||
}
|
||||
|
||||
if (_multiple != nil && ([_multiple boolValueInComponent:component])) {
|
||||
[_filepath setValue:fileNameValue
|
||||
inComponent:component];
|
||||
|
||||
[_data setValue:fileDatas
|
||||
inComponent:component];
|
||||
|
||||
[_mimeType setValue:mimeValue
|
||||
inComponent:component];
|
||||
} else {
|
||||
|
||||
[_filepath setValue:[fileNameValue objectAtIndex:0]
|
||||
inComponent:component];
|
||||
|
||||
[_data setValue:[fileDatas objectAtIndex:0]
|
||||
inComponent:component];
|
||||
|
||||
[_mimeType setValue:[mimeValue objectAtIndex:0]
|
||||
inComponent:component];
|
||||
|
||||
if (_multiple != nil
|
||||
&& [_multiple boolValueInComponent:component])
|
||||
{
|
||||
[_filepath setValue:fileNameValue
|
||||
inComponent:component];
|
||||
|
||||
[_data setValue:fileDatas
|
||||
inComponent:component];
|
||||
|
||||
[_mimeType setValue:mimeValue
|
||||
inComponent:component];
|
||||
}
|
||||
else
|
||||
{
|
||||
[_filepath setValue:[fileNameValue objectAtIndex:0]
|
||||
inComponent:component];
|
||||
|
||||
[_data setValue:[fileDatas objectAtIndex:0]
|
||||
inComponent:component];
|
||||
|
||||
[_mimeType setValue:[mimeValue objectAtIndex:0]
|
||||
inComponent:component];
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
NS_HANDLER
|
||||
{
|
||||
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
|
||||
@"GSWFileUpload in takeValuesFromRequest");
|
||||
[localException raise];
|
||||
localException=ExceptionByAddingUserInfoObjectFrameInfo0(localException,
|
||||
@"GSWFileUpload in takeValuesFromRequest");
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER;
|
||||
NS_ENDHANDLER;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,18 +43,9 @@
|
|||
GSWAssociation * _directActionName;
|
||||
};
|
||||
|
||||
-(void)appendToResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)context;
|
||||
|
||||
-(void)_appendHiddenFieldsToResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)context;
|
||||
|
||||
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context;
|
||||
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context;
|
||||
|
||||
@end
|
||||
|
||||
#endif //_GSWForm_h__
|
||||
|
|
237
GSWeb/GSWForm.m
237
GSWeb/GSWForm.m
|
@ -40,6 +40,7 @@ static Class standardClass = Nil;
|
|||
//====================================================================
|
||||
@implementation GSWForm
|
||||
|
||||
static GSWAssociation* static_defaultMethodAssociation = nil;
|
||||
//--------------------------------------------------------------------
|
||||
+ (void) initialize
|
||||
{
|
||||
|
@ -49,79 +50,64 @@ static Class standardClass = Nil;
|
|||
|
||||
standardEvaluateConditionInContextIMP =
|
||||
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
|
||||
|
||||
ASSIGN(static_defaultMethodAssociation,([GSWAssociation associationWithValue:@"post"]));
|
||||
};
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)name
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
GSWConstantValueAssociation * methodAssoc = nil;
|
||||
|
||||
self = [super initWithName:@"form" associations:associations template:template];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
DESTROY(_otherQueryAssociations);
|
||||
_otherQueryAssociations = RETAIN([_associations extractObjectsForKeysWithPrefix:@"?" removePrefix: YES]);
|
||||
if ((self = [super initWithName:@"form"
|
||||
associations:associations
|
||||
template:template]))
|
||||
{
|
||||
DESTROY(_otherQueryAssociations);
|
||||
_otherQueryAssociations = RETAIN([_associations extractObjectsForKeysWithPrefix:@"?" removePrefix: YES]);
|
||||
|
||||
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)) {
|
||||
if ([_otherQueryAssociations count] == 0)
|
||||
DESTROY(_otherQueryAssociations);
|
||||
|
||||
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))) {
|
||||
GSWAssignAndRemoveAssociation(&_action,_associations,action__Key);
|
||||
GSWAssignAndRemoveAssociation(&_href,_associations,href__Key);
|
||||
GSWAssignAndRemoveAssociation(&_multipleSubmit,_associations,multipleSubmit__Key);
|
||||
GSWAssignAndRemoveAssociation(&_actionClass,_associations,actionClass__Key);
|
||||
GSWAssignAndRemoveAssociation(&_queryDictionary,_associations,queryDictionary__Key);
|
||||
GSWAssignAndRemoveAssociation(&_directActionName,_associations,directActionName__Key);
|
||||
|
||||
[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__];
|
||||
|
||||
}
|
||||
if ([_associations objectForKey:method__Key] == nil
|
||||
&& [_associations objectForKey:@"Method"] == nil
|
||||
&& [_associations objectForKey:@"METHOD"] == nil)
|
||||
{
|
||||
[_associations setObject: static_defaultMethodAssociation
|
||||
forKey:method__Key];
|
||||
}
|
||||
|
||||
if ((_action != nil && _href != nil)
|
||||
|| (_action != nil && _directActionName != nil)
|
||||
|| (_href != nil && _directActionName != nil)
|
||||
|| (_action != nil && _actionClass != nil)
|
||||
|| (_href != nil && _actionClass != nil))
|
||||
{
|
||||
[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
|
||||
{
|
||||
DESTROY(_action);
|
||||
|
@ -135,6 +121,7 @@ static Class standardClass = Nil;
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id) description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%s %p action: %@ actionClass: %@ directActionName: %@ href:%@ multipleSubmit: %@ queryDictionary: %@ otherQueryAssociations: %@ >",
|
||||
|
@ -143,23 +130,24 @@ static Class standardClass = Nil;
|
|||
_queryDictionary, _otherQueryAssociations];
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (void) _enterFormInContext:(GSWContext *) context
|
||||
{
|
||||
[context setInForm:YES];
|
||||
if ([[context elementID] isEqual:[context senderID]]) {
|
||||
if ([[context elementID] isEqual:[context senderID]])
|
||||
[context _setFormSubmitted:YES];
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (void) _exitFormInContext:(GSWContext *) context
|
||||
{
|
||||
[context setInForm:NO];
|
||||
[context _setFormSubmitted:NO];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context;
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
[self _enterFormInContext:context];
|
||||
[super takeValuesFromRequest:request
|
||||
|
@ -167,64 +155,70 @@ static Class standardClass = Nil;
|
|||
[self _exitFormInContext:context];
|
||||
}
|
||||
|
||||
-(GSWElement*)invokeActionForRequest:(GSWRequest*) request
|
||||
inContext:(GSWContext*) context
|
||||
//--------------------------------------------------------------------
|
||||
-(id <GSWActionResults>)invokeActionForRequest:(GSWRequest*) request
|
||||
inContext:(GSWContext*) context
|
||||
|
||||
{
|
||||
id supervalue = nil;
|
||||
id <GSWActionResults> result = nil;
|
||||
|
||||
[self _enterFormInContext:context];
|
||||
[context _setActionInvoked:NO];
|
||||
[context _setIsMultipleSubmitForm:(_multipleSubmit == nil ? NO : [_multipleSubmit boolValueInComponent:[context component]])];
|
||||
[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]];
|
||||
result = [super invokeActionForRequest:request
|
||||
inContext:context];
|
||||
if (![context _wasActionInvoked]
|
||||
&& [context _wasFormSubmitted])
|
||||
{
|
||||
if (_action != nil)
|
||||
result = [_action valueInComponent:[context component]];
|
||||
if (result == nil)
|
||||
result = [context page];
|
||||
}
|
||||
if (supervalue == nil) {
|
||||
supervalue = [context page];
|
||||
}
|
||||
}
|
||||
[context _setIsMultipleSubmitForm:NO];
|
||||
[self _exitFormInContext:context];
|
||||
|
||||
return supervalue;
|
||||
return result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendHiddenFieldsToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
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, NSStringWithObject(value), NO);
|
||||
GSWResponse_appendContentAsciiString(response,@">\n");
|
||||
}
|
||||
if ([queryDict count] > 0)
|
||||
{
|
||||
NSEnumerator* myEnumer = [queryDict keyEnumerator];
|
||||
NSString* key=nil;
|
||||
|
||||
}
|
||||
while ((key = [myEnumer nextObject]))
|
||||
{
|
||||
NSString* value = NSStringWithObject([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];
|
||||
[super appendToResponse: response
|
||||
inContext: context];
|
||||
[context setInForm:NO];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendChildrenToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -235,6 +229,7 @@ static Class standardClass = Nil;
|
|||
inContext:context];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendCGIActionToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -249,32 +244,48 @@ static Class standardClass = Nil;
|
|||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, action__Key, myActionURL, NO);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendAttributesToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
inContext:(GSWContext*) aContext
|
||||
{
|
||||
NSString * value = nil;
|
||||
GSWComponent * component = [context component];
|
||||
GSWComponent * component = GSWContext_component(aContext);
|
||||
|
||||
[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);
|
||||
}
|
||||
[super appendAttributesToResponse:response
|
||||
inContext:aContext];
|
||||
|
||||
|
||||
if (_directActionName != nil
|
||||
|| _actionClass != nil)
|
||||
{
|
||||
[self _appendCGIActionToResponse:response
|
||||
inContext: aContext];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString* href=[_href valueInComponent:component];
|
||||
if (href != nil)
|
||||
{
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
action__Key,
|
||||
NSStringWithObject(href),
|
||||
NO);
|
||||
}
|
||||
else if (_href == nil)
|
||||
{
|
||||
BOOL secure = (_secure != nil ? [_secure boolValueInComponent:component] : NO);
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
action__Key,
|
||||
[aContext _componentActionURLIsSecure:secure],
|
||||
NO);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"%s: action attribute evaluates to null. %@", __PRETTY_FUNCTION__, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
+(BOOL)hasGSWebObjectsAssociations
|
||||
{
|
||||
return NO;
|
||||
|
|
|
@ -34,16 +34,6 @@
|
|||
|
||||
//====================================================================
|
||||
@interface GSWFrame: GSWHTMLURLValuedElement
|
||||
|
||||
-(id)initWithName:(NSString*)name
|
||||
associations:(NSDictionary*)associations
|
||||
contentElements:(NSArray*)elements;
|
||||
-(void)dealloc;
|
||||
-(NSString*)valueAttributeName;
|
||||
-(NSString*)urlAttributeName;
|
||||
-(NSString*)elementName;
|
||||
-(NSString*)description;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
|
@ -39,10 +39,9 @@ RCS_ID("$Id$")
|
|||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)name
|
||||
associations:(NSDictionary*)associations
|
||||
contentElements:(NSArray*)elements
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
NSString* elementName=[self elementName];
|
||||
if ((self=[super initWithName:elementName
|
||||
if ((self=[super initWithName:@"frame"
|
||||
associations:associations
|
||||
contentElements:nil]))
|
||||
{
|
||||
|
@ -50,39 +49,6 @@ RCS_ID("$Id$")
|
|||
return self;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)valueAttributeName
|
||||
{
|
||||
return @"value";
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)urlAttributeName
|
||||
{
|
||||
return @"src";
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)elementName
|
||||
{
|
||||
return @"FRAME";
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%s %p>",
|
||||
object_getClassName(self),
|
||||
(void*)self];
|
||||
};
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
|
@ -32,28 +32,9 @@
|
|||
#ifndef _GSWGenericContainer_h__
|
||||
#define _GSWGenericContainer_h__
|
||||
|
||||
|
||||
#include "GSWGenericElement.h"
|
||||
//====================================================================
|
||||
@interface GSWGenericContainer: GSWDynamicElement
|
||||
{
|
||||
GSWAssociation* _elementName;
|
||||
GSWAssociation* _otherTagString;
|
||||
GSWAssociation* _omitElement;
|
||||
GSWAssociation* _children;
|
||||
NSDictionary* _associations;
|
||||
GSWElement* _element;
|
||||
};
|
||||
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)templateElement;
|
||||
|
||||
-(void)appendToResponse:(GSWResponse*)aResponse
|
||||
inContext:(GSWContext*)aContext;
|
||||
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)aRequest
|
||||
inContext:(GSWContext*)aContext;
|
||||
|
||||
@interface GSWGenericContainer: GSWGenericElement
|
||||
@end
|
||||
|
||||
#endif //_GSWGenericContainer_h__
|
||||
|
|
|
@ -46,144 +46,68 @@ static Class GSWHTMLBareStringClass = Nil;
|
|||
};
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)templateElement
|
||||
{
|
||||
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
|
||||
|
||||
_elementName = [[associations objectForKey:elementName__Key
|
||||
withDefaultObject:[_elementName autorelease]] retain];
|
||||
|
||||
_otherTagString = [[associations objectForKey:otherTagString__Key
|
||||
withDefaultObject:[_otherTagString autorelease]] retain];
|
||||
|
||||
[tmpAssociations removeObjectForKey:elementName__Key];
|
||||
[tmpAssociations removeObjectForKey:otherTagString__Key];
|
||||
|
||||
if (!WOStrictFlag)
|
||||
{
|
||||
_omitElement = [[associations objectForKey:omitElement__Key
|
||||
withDefaultObject:[_omitElement autorelease]] retain];
|
||||
|
||||
[tmpAssociations removeObjectForKey:omitElement__Key];
|
||||
};
|
||||
|
||||
|
||||
if ((self=[super initWithName:aName
|
||||
associations:tmpAssociations
|
||||
associations:associations
|
||||
template:templateElement]))
|
||||
{
|
||||
if ([tmpAssociations count]>0)
|
||||
ASSIGN(_associations,tmpAssociations);
|
||||
ASSIGN(_element,templateElement);
|
||||
};
|
||||
return self;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)dealloc
|
||||
{
|
||||
DESTROY(_elementName);
|
||||
DESTROY(_otherTagString);
|
||||
DESTROY(_omitElement);
|
||||
DESTROY(_associations);
|
||||
DESTROY(_element);
|
||||
[super dealloc];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)description
|
||||
{
|
||||
//TODOFN
|
||||
return [super description];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
-(void)appendToResponse:(GSWResponse*)aResponse
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
NSEnumerator *assocEnumer=nil;
|
||||
id currentAssocKey=nil;
|
||||
id component = GSWContext_component(aContext);
|
||||
id theValue=nil;
|
||||
id otherTag = nil;
|
||||
id tag = nil;
|
||||
BOOL omitElement = NO;
|
||||
|
||||
if (!WOStrictFlag && _omitElement)
|
||||
{
|
||||
omitElement=[self evaluateCondition:_omitElement
|
||||
inContext:aContext
|
||||
noConditionAssociationDefault:NO
|
||||
noConditionDefault:NO];
|
||||
};
|
||||
|
||||
if (!omitElement)
|
||||
{
|
||||
tag = [_elementName valueInComponent:component];
|
||||
|
||||
GSWResponse_appendContentCharacter(aResponse,'<');
|
||||
GSWResponse_appendContentString(aResponse,tag);
|
||||
|
||||
if ((otherTag = [_otherTagString valueInComponent:component]))
|
||||
{
|
||||
GSWResponse_appendContentCharacter(aResponse,' ');
|
||||
GSWResponse_appendContentString(aResponse,otherTag);
|
||||
}
|
||||
|
||||
assocEnumer = [_associations keyEnumerator];
|
||||
while ((currentAssocKey = [assocEnumer nextObject]))
|
||||
{
|
||||
theValue = NSStringWithObject([[_associations objectForKey:currentAssocKey]
|
||||
valueInComponent:component]);
|
||||
|
||||
GSWResponse_appendContentCharacter(aResponse,' ');
|
||||
GSWResponse_appendContentString(aResponse,currentAssocKey);
|
||||
GSWResponse_appendContentAsciiString(aResponse,@"=\"");
|
||||
GSWResponse_appendContentString(aResponse,theValue);
|
||||
GSWResponse_appendContentCharacter(aResponse,'"');
|
||||
}
|
||||
|
||||
GSWResponse_appendContentCharacter(aResponse,'>');
|
||||
};
|
||||
|
||||
[_element appendToResponse:aResponse
|
||||
inContext:aContext];
|
||||
|
||||
if (!omitElement)
|
||||
{
|
||||
GSWResponse_appendContentAsciiString(aResponse,@"</");
|
||||
GSWResponse_appendContentString(aResponse,tag);
|
||||
GSWResponse_appendContentCharacter(aResponse,'>');
|
||||
};
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
-(id <GSWActionResults>)invokeActionForRequest:(GSWRequest*)aRequest
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
|
||||
if ([_element class] != GSWHTMLBareStringClass) {
|
||||
|
||||
return [_element invokeActionForRequest:aRequest
|
||||
inContext:aContext];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)aRequest
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
[_element takeValuesFromRequest:aRequest
|
||||
inContext:aContext];
|
||||
};
|
||||
//Call super and next children because it inherit from GSWGenericElement
|
||||
[super takeValuesFromRequest:aRequest
|
||||
inContext:aContext];
|
||||
[self takeChildrenValuesFromRequest:aRequest
|
||||
inContext:aContext];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------
|
||||
-(id <GSWActionResults>)invokeActionForRequest:(GSWRequest*)aRequest
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
//Call super and next children because it inherit from GSWGenericElement
|
||||
id <GSWActionResults> actionResult = [super invokeActionForRequest:aRequest
|
||||
inContext:aContext];
|
||||
if (actionResult == nil)
|
||||
{
|
||||
actionResult = [self invokeChildrenActionForRequest:aRequest
|
||||
inContext:aContext];
|
||||
}
|
||||
return actionResult;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)appendToResponse:(GSWResponse*)aResponse
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
//Call super and next children because it inherit from GSWGenericElement
|
||||
NSString* elementName = nil;
|
||||
[super appendToResponse:aResponse
|
||||
inContext:aContext];
|
||||
|
||||
//get elementName after super appendToResponse:inContext: because GSWGenericElement set elementName in it !
|
||||
elementName = [self elementName];
|
||||
|
||||
[self appendChildrenToResponse:aResponse
|
||||
inContext:aContext];
|
||||
|
||||
if (elementName != nil)
|
||||
{
|
||||
GSWResponse_appendContentCharacter(aResponse,'<');
|
||||
GSWResponse_appendContentCharacter(aResponse,'/');
|
||||
GSWResponse_appendContentString(aResponse,elementName);
|
||||
GSWResponse_appendContentCharacter(aResponse,'>');
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
//OK
|
||||
//====================================================================
|
||||
@interface GSWGenericElement: GSWDynamicElement
|
||||
@interface GSWGenericElement: GSWHTMLDynamicElement
|
||||
{
|
||||
GSWAssociation* _elementName;
|
||||
GSWAssociation* _name;
|
||||
|
@ -43,37 +43,9 @@
|
|||
GSWAssociation* _invokeAction;
|
||||
GSWAssociation* _elementID;
|
||||
GSWAssociation* _otherTagString;
|
||||
NSDictionary* _otherAssociations;
|
||||
BOOL _hasFormValues;
|
||||
};
|
||||
|
||||
-(id)initWithName:(NSString*)name
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)templateElement;
|
||||
|
||||
-(void)dealloc;
|
||||
-(NSString*)description;
|
||||
|
||||
-(void)appendToResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)context;
|
||||
|
||||
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context;
|
||||
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context;
|
||||
|
||||
-(id)_elementNameAppendToResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)context;
|
||||
|
||||
-(void)_appendTagWithName:(NSString*)name
|
||||
toResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)context;
|
||||
|
||||
-(void)_appendOtherAttributesToResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)context;
|
||||
|
||||
-(NSString*)_elementNameInContext:(GSWContext*)context;
|
||||
@end
|
||||
|
||||
#endif //_GSWGenericElement_h__
|
||||
|
|
|
@ -57,21 +57,18 @@ static Class standardClass = Nil;
|
|||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)templateElement
|
||||
{
|
||||
|
||||
if ((self=[super initWithName: name
|
||||
associations: associations
|
||||
template: templateElement]))
|
||||
{
|
||||
NSMutableDictionary *dict=nil;
|
||||
|
||||
ASSIGN(_elementName, [associations objectForKey: elementName__Key]);
|
||||
ASSIGN(_name, [associations objectForKey: name__Key]);
|
||||
ASSIGN(_omitTags, [associations objectForKey: omitTags__Key]);
|
||||
ASSIGN(_formValue, [associations objectForKey: formValue__Key]);
|
||||
ASSIGN(_formValues, [associations objectForKey: formValues__Key]);
|
||||
ASSIGN(_invokeAction, [associations objectForKey: invokeAction__Key]);
|
||||
ASSIGN(_elementID, [associations objectForKey: elementID__Key]);
|
||||
ASSIGN(_otherTagString, [associations objectForKey: otherTagString__Key]);
|
||||
GSWAssignAndRemoveAssociation(&_elementName,_associations,elementName__Key);
|
||||
GSWAssignAndRemoveAssociation(&_omitTags,_associations,omitTags__Key);
|
||||
GSWAssignAndRemoveAssociation(&_formValue,_associations,formValue__Key);
|
||||
GSWAssignAndRemoveAssociation(&_formValues,_associations,formValues__Key);
|
||||
GSWAssignAndRemoveAssociation(&_invokeAction,_associations,invokeAction__Key);
|
||||
GSWAssignAndRemoveAssociation(&_elementID,_associations,elementID__Key);
|
||||
GSWAssignAndRemoveAssociation(&_otherTagString,_associations,otherTagString__Key);
|
||||
GSWAssignAndRemoveAssociation(&_name,_associations,name__Key);
|
||||
|
||||
if(_formValue || _formValues)
|
||||
{
|
||||
|
@ -86,28 +83,15 @@ static Class standardClass = Nil;
|
|||
associations];
|
||||
}
|
||||
}
|
||||
|
||||
dict = AUTORELEASE([associations mutableCopy]);
|
||||
|
||||
[dict removeObjectForKey: elementName__Key];
|
||||
[dict removeObjectForKey: name__Key];
|
||||
[dict removeObjectForKey: omitTags__Key];
|
||||
[dict removeObjectForKey: formValue__Key];
|
||||
[dict removeObjectForKey: formValues__Key];
|
||||
[dict removeObjectForKey: invokeAction__Key];
|
||||
[dict removeObjectForKey: elementID__Key];
|
||||
[dict removeObjectForKey: otherTagString__Key];
|
||||
|
||||
ASSIGNCOPY(_otherAssociations, dict);
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)dealloc
|
||||
{
|
||||
RELEASE (_elementName);
|
||||
RELEASE (_name);
|
||||
RELEASE (_omitTags);
|
||||
RELEASE (_formValue);
|
||||
|
@ -115,7 +99,6 @@ static Class standardClass = Nil;
|
|||
RELEASE (_invokeAction);
|
||||
RELEASE (_elementID);
|
||||
RELEASE (_otherTagString);
|
||||
RELEASE (_otherAssociations);
|
||||
[super dealloc];
|
||||
};
|
||||
|
||||
|
@ -123,17 +106,30 @@ static Class standardClass = Nil;
|
|||
-(NSString*)description
|
||||
{
|
||||
return [NSString stringWithFormat:@"%@(%p)\n(%@)",
|
||||
NSStringFromClass([self class]), self, _otherAssociations];
|
||||
NSStringFromClass([self class]), self, _associations];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)appendToResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)context
|
||||
-(NSString*)_elementNameInContext:(GSWContext*)aContext
|
||||
{
|
||||
NSString* elementName = nil;
|
||||
if (_elementName)
|
||||
{
|
||||
BOOL omit = NO;
|
||||
if (_omitTags)
|
||||
{
|
||||
omit = GSWDynamicElement_evaluateValueInContext(self,standardClass,
|
||||
standardEvaluateConditionInContextIMP,
|
||||
_omitTags,aContext);
|
||||
}
|
||||
|
||||
if (omit == NO)
|
||||
{
|
||||
elementName=[_elementName valueInComponent:GSWContext_component(aContext)];
|
||||
}
|
||||
}
|
||||
|
||||
[self _elementNameAppendToResponse: response
|
||||
inContext: context];
|
||||
|
||||
return elementName;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -141,10 +137,7 @@ static Class standardClass = Nil;
|
|||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
GSWElement *element = nil;
|
||||
GSWComponent *component = nil;
|
||||
|
||||
|
||||
component = GSWContext_component(aContext);
|
||||
GSWComponent *component = GSWContext_component(aContext);
|
||||
|
||||
if (_invokeAction != nil
|
||||
&& [_invokeAction isImplementedForComponent:component])
|
||||
|
@ -158,32 +151,35 @@ static Class standardClass = Nil;
|
|||
if ([elementID isEqualToString: senderID])
|
||||
{
|
||||
if (_elementID != nil)
|
||||
{
|
||||
[_elementID setValue: elementID
|
||||
inComponent: component];
|
||||
}
|
||||
|
||||
element = [_invokeAction valueInComponent:component];
|
||||
if (!element)
|
||||
if (element==nil)
|
||||
element = [aContext page];
|
||||
}
|
||||
else if (_name)
|
||||
{
|
||||
id nameValue = [_name valueInComponent:component];
|
||||
id formValue = [request stringFormValueForKey:nameValue];
|
||||
NSString* name = NSStringWithObject([_name valueInComponent:component]);
|
||||
id formValue = [request stringFormValueForKey:name];
|
||||
|
||||
if (formValue)
|
||||
{
|
||||
if(_elementID)
|
||||
[_elementID setValue: elementID
|
||||
inComponent:component];
|
||||
{
|
||||
[_elementID setValue: elementID
|
||||
inComponent:component];
|
||||
}
|
||||
|
||||
element = [_invokeAction valueInComponent: component];
|
||||
if (!element)
|
||||
if (element==nil)
|
||||
element = [aContext page];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
|
@ -191,12 +187,11 @@ static Class standardClass = Nil;
|
|||
-(void)takeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
|
||||
if (_hasFormValues)
|
||||
{
|
||||
GSWComponent *component = GSWContext_component(aContext);
|
||||
NSString *elementID = GSWContext_elementID(aContext);
|
||||
id nameValue = [_name valueInComponent: component];
|
||||
NSString* name = NSStringWithObject([_name valueInComponent: component]);
|
||||
|
||||
if (_elementID != nil)
|
||||
{
|
||||
|
@ -205,142 +200,70 @@ static Class standardClass = Nil;
|
|||
}
|
||||
if (_formValue != nil)
|
||||
{
|
||||
[_formValue setValue: [request stringFormValueForKey: nameValue]
|
||||
[_formValue setValue: [request stringFormValueForKey: name]
|
||||
inComponent: component];
|
||||
}
|
||||
if (_formValues != nil)
|
||||
{
|
||||
[_formValue setValue: [request formValuesForKey: nameValue]
|
||||
[_formValue setValue: [request formValuesForKey: name]
|
||||
inComponent: component];
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)_elementNameAppendToResponse:(GSWResponse*)response
|
||||
//--------------------------------------------------------------------
|
||||
-(void)appendAttributesToResponse:(GSWResponse*)aResponse
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
NSString *elementName = nil;
|
||||
|
||||
|
||||
if (_elementID != nil)
|
||||
{
|
||||
[_elementID setValue: GSWContext_elementID(aContext)
|
||||
inComponent: GSWContext_component(aContext)];
|
||||
}
|
||||
|
||||
elementName = [self _elementNameInContext: aContext];
|
||||
NSDebugMLog(@"elementName=%@",elementName);
|
||||
|
||||
if (elementName != nil)
|
||||
{
|
||||
[self _appendTagWithName: elementName
|
||||
toResponse: response
|
||||
inContext: aContext];
|
||||
}
|
||||
|
||||
|
||||
return elementName;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)_appendTagWithName:(NSString*)name
|
||||
toResponse:(GSWResponse*)aResponse
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
GSWComponent *comp = nil;
|
||||
|
||||
|
||||
comp = GSWContext_component(aContext);
|
||||
GSWResponse_appendContentCharacter(aResponse,'<');
|
||||
GSWResponse_appendContentString(aResponse, name);
|
||||
GSWComponent *component = GSWContext_component(aContext);
|
||||
if (_name != nil)
|
||||
{
|
||||
NSString *compName = [_name valueInComponent: comp];
|
||||
GSWResponse_appendContentAsciiString(aResponse, @" name=\"");
|
||||
GSWResponse_appendContentString(aResponse, compName);
|
||||
GSWResponse_appendContentCharacter(aResponse, '"');
|
||||
NSString* name = NSStringWithObject([_name valueInComponent:component]);
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,@"name",name,YES);
|
||||
}
|
||||
if (_otherAssociations != nil)
|
||||
|
||||
if(_otherTagString != nil)
|
||||
{
|
||||
[self _appendOtherAttributesToResponse: aResponse
|
||||
inContext: aContext];
|
||||
}
|
||||
if (_otherTagString != nil)
|
||||
{
|
||||
NSString *oTagComp = [_otherTagString valueInComponent: comp];
|
||||
if (oTagComp != nil && [oTagComp length])
|
||||
NSString* otherTagString = NSStringWithObject([_otherTagString valueInComponent:component]);
|
||||
if ([otherTagString length]>0)
|
||||
{
|
||||
GSWResponse_appendContentCharacter(aResponse, ' ');
|
||||
GSWResponse_appendContentString(aResponse, oTagComp);
|
||||
GSWResponse_appendContentCharacter(aResponse,' ');
|
||||
GSWResponse_appendContentString(aResponse,otherTagString);
|
||||
}
|
||||
}
|
||||
GSWResponse_appendContentCharacter(aResponse, '>');
|
||||
|
||||
};
|
||||
[self appendConstantAttributesToResponse:aResponse
|
||||
inContext:aContext];
|
||||
[self appendNonURLAttributesToResponse:aResponse
|
||||
inContext:aContext];
|
||||
[self appendURLAttributesToResponse:aResponse
|
||||
inContext:aContext];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)_appendOtherAttributesToResponse:(GSWResponse*)aResponse
|
||||
inContext:(GSWContext*)aContext
|
||||
-(void)appendToResponse:(GSWResponse*)aResponse
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
GSWComponent *comp = nil;
|
||||
NSEnumerator *keyEnum = nil;
|
||||
NSString *key = nil;
|
||||
|
||||
|
||||
comp = GSWContext_component(aContext);
|
||||
keyEnum = [_otherAssociations keyEnumerator];
|
||||
|
||||
while ((key = [keyEnum nextObject]))
|
||||
if (aContext != nil
|
||||
&& aResponse != nil)
|
||||
{
|
||||
GSWAssociation *assoc;
|
||||
id val;
|
||||
NSString *desc;
|
||||
|
||||
assoc = [_otherAssociations objectForKey: key];
|
||||
val = [assoc valueInComponent: comp];
|
||||
if (val != nil)
|
||||
{
|
||||
desc = [val description];
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(aResponse,
|
||||
key,
|
||||
desc,
|
||||
NO);
|
||||
if (_elementID != nil)
|
||||
{
|
||||
GSWComponent *component = GSWContext_component(aContext);
|
||||
[_elementID setValue:[aContext elementID]
|
||||
inComponent:component];
|
||||
}
|
||||
ASSIGN(_dynElementName,([self _elementNameInContext:aContext]));
|
||||
if (_dynElementName != nil)
|
||||
{
|
||||
GSWResponse_appendContentCharacter(aResponse,'<');
|
||||
GSWResponse_appendContentAsciiString(aResponse,_dynElementName);
|
||||
[self appendAttributesToResponse:aResponse
|
||||
inContext:aContext];
|
||||
GSWResponse_appendContentCharacter(aResponse,'>');
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)_elementNameInContext:(GSWContext*)aContext
|
||||
{
|
||||
NSString* elementName = nil;
|
||||
|
||||
|
||||
NSDebugMLog(@"_elementName=%@",_elementName);
|
||||
|
||||
if (_elementName)
|
||||
{
|
||||
BOOL omit = NO;
|
||||
|
||||
if (_omitTags)
|
||||
{
|
||||
omit = GSWDynamicElement_evaluateValueInContext(self,standardClass,
|
||||
standardEvaluateConditionInContextIMP,
|
||||
_omitTags,aContext);
|
||||
}
|
||||
|
||||
if (omit == NO)
|
||||
{
|
||||
elementName=[_elementName valueInComponent:GSWContext_component(aContext)];
|
||||
}
|
||||
}
|
||||
|
||||
NSDebugMLog(@"elementName=%@",elementName);
|
||||
|
||||
|
||||
return elementName;
|
||||
};
|
||||
|
||||
@end
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
//====================================================================
|
||||
@interface GSWHTMLDynamicElement: GSWDynamicGroup
|
||||
{
|
||||
NSString * _elementName;
|
||||
NSString * _dynElementName;
|
||||
NSMutableDictionary * _nonURLAttributeAssociations;
|
||||
NSMutableDictionary * _urlAttributeAssociations;
|
||||
NSString * _constantAttributesRepresentation;
|
||||
|
|
|
@ -47,12 +47,10 @@ static NSMutableDictionary * _urlAttributesTable = nil;
|
|||
|
||||
static inline BOOL _needQuote(NSString* str_needQuote)
|
||||
{
|
||||
if ([str_needQuote isKindOfClass:NSStringClass] == NO) {
|
||||
return NO;
|
||||
} else {
|
||||
unsigned int mystrlen = [str_needQuote length];
|
||||
return (((mystrlen < 1) || ([str_needQuote hasPrefix:@"\""] == NO)) || ([str_needQuote hasSuffix:@"\""] == NO));
|
||||
}
|
||||
return (mystrlen == 0
|
||||
|| [str_needQuote hasPrefix:@"\""] == NO
|
||||
|| [str_needQuote hasSuffix:@"\""] == NO);
|
||||
}
|
||||
|
||||
//====================================================================
|
||||
|
@ -63,50 +61,52 @@ static inline BOOL _needQuote(NSString* str_needQuote)
|
|||
{
|
||||
if (self == [GSWHTMLDynamicElement class])
|
||||
{
|
||||
if (!_urlAttributesTable) {
|
||||
_urlAttributesTable = [NSMutableDictionary new];
|
||||
[_urlAttributesTable setObject:@"href" forKey:@"a"];
|
||||
[_urlAttributesTable setObject:@"codebase" forKey:@"applet"];
|
||||
[_urlAttributesTable setObject:@"href" forKey:@"area"];
|
||||
[_urlAttributesTable setObject:@"src" forKey:@"bgsound"];
|
||||
[_urlAttributesTable setObject:@"href" forKey:@"base"];
|
||||
[_urlAttributesTable setObject:@"background" forKey:@"body"];
|
||||
[_urlAttributesTable setObject:@"src" forKey:@"embed"];
|
||||
[_urlAttributesTable setObject:@"action" forKey:@"form"];
|
||||
[_urlAttributesTable setObject:@"src" forKey:@"frame"];
|
||||
[_urlAttributesTable setObject:[NSArray arrayWithObjects:@"src",@"dynsrc",@"usemap",nil]
|
||||
forKey:@"img"];
|
||||
[_urlAttributesTable setObject:@"src" forKey:@"input"];
|
||||
[_urlAttributesTable setObject:@"href" forKey:@"link"];
|
||||
[_urlAttributesTable setObject:@"src" forKey:@"script"];
|
||||
if (!_urlAttributesTable)
|
||||
{
|
||||
_urlAttributesTable = [NSMutableDictionary new];
|
||||
[_urlAttributesTable setObject:@"href" forKey:@"a"];
|
||||
[_urlAttributesTable setObject:@"codebase" forKey:@"applet"];
|
||||
[_urlAttributesTable setObject:@"href" forKey:@"area"];
|
||||
[_urlAttributesTable setObject:@"src" forKey:@"bgsound"];
|
||||
[_urlAttributesTable setObject:@"href" forKey:@"base"];
|
||||
[_urlAttributesTable setObject:@"background" forKey:@"body"];
|
||||
[_urlAttributesTable setObject:@"src" forKey:@"embed"];
|
||||
[_urlAttributesTable setObject:@"action" forKey:@"form"];
|
||||
[_urlAttributesTable setObject:@"src" forKey:@"frame"];
|
||||
[_urlAttributesTable setObject:[NSArray arrayWithObjects:@"src",@"dynsrc",@"usemap",nil]
|
||||
forKey:@"img"];
|
||||
[_urlAttributesTable setObject:@"src" forKey:@"input"];
|
||||
[_urlAttributesTable setObject:@"href" forKey:@"link"];
|
||||
[_urlAttributesTable setObject:@"src" forKey:@"script"];
|
||||
|
||||
NSStringClass = [NSString class];
|
||||
NSNumberClass = [NSNumber class];
|
||||
NSMutableDictionaryClass = [NSMutableDictionary class];
|
||||
GSCachedIntClass = NSClassFromString(@"GSCachedInt");
|
||||
NSStringClass = [NSString class];
|
||||
NSNumberClass = [NSNumber class];
|
||||
NSMutableDictionaryClass = [NSMutableDictionary class];
|
||||
GSCachedIntClass = NSClassFromString(@"GSCachedInt");
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// returns string or array or nil.
|
||||
+ (id) _urlAttributesForElementNamed:(NSString*) str
|
||||
{
|
||||
id result = nil;
|
||||
if (str == nil) {
|
||||
return nil;
|
||||
} else {
|
||||
result = [_urlAttributesTable objectForKey:[str lowercaseString]];
|
||||
if (!result) {
|
||||
NSLog(@"%s:%@ %@ ", __PRETTY_FUNCTION__ , str, self);
|
||||
if (str != nil)
|
||||
{
|
||||
result = [_urlAttributesTable objectForKey:[str lowercaseString]];
|
||||
if (!result)
|
||||
{
|
||||
NSLog(@"%s:%@ %@ ", __PRETTY_FUNCTION__ , str, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) dealloc
|
||||
{
|
||||
DESTROY(_elementName);
|
||||
DESTROY(_dynElementName);
|
||||
DESTROY(_nonURLAttributeAssociations);
|
||||
DESTROY(_urlAttributeAssociations);
|
||||
DESTROY(_constantAttributesRepresentation);
|
||||
|
@ -117,197 +117,199 @@ static inline BOOL _needQuote(NSString* str_needQuote)
|
|||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(BOOL) escapeHTML
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)name
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
self = [super initWithName:nil
|
||||
associations:nil
|
||||
template: template];
|
||||
|
||||
ASSIGN(_elementName, name);
|
||||
if (associations == nil) {
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: No associations",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
DESTROY(_associations);
|
||||
_associations = [associations mutableCopyWithZone:[self zone]];
|
||||
_finishedInitialization = NO;
|
||||
|
||||
if ((self = [super initWithName:nil
|
||||
associations:nil
|
||||
template: template]))
|
||||
{
|
||||
ASSIGN(_dynElementName, name);
|
||||
if (associations == nil)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: No associations",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
DESTROY(_associations);
|
||||
_associations = [associations mutableCopyWithZone:[self zone]];
|
||||
_finishedInitialization = NO;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)name
|
||||
associations:(NSDictionary*)associations
|
||||
contentElements:(NSMutableArray*) children
|
||||
{
|
||||
|
||||
// I am not sure if this mehod should exist here at all. dave@turbocat.de
|
||||
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: sure you want this?",
|
||||
__PRETTY_FUNCTION__];
|
||||
//
|
||||
// self = [super initWithName:nil
|
||||
// associations:nil
|
||||
// contentElements:children];
|
||||
//
|
||||
// ASSIGN(_elementName, name);
|
||||
// if (associations == nil) {
|
||||
// [NSException raise:NSInvalidArgumentException
|
||||
// format:@"%s: No associations",
|
||||
// __PRETTY_FUNCTION__];
|
||||
// }
|
||||
// DESTROY(_associations);
|
||||
// _associations = [associations mutableCopyWithZone:nil];
|
||||
// _finishedInitialization = NO;
|
||||
//
|
||||
// I am not sure if this mehod should exist here at all. dave@turbocat.de
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: sure you want this?",
|
||||
__PRETTY_FUNCTION__];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (void) _finishInitialization
|
||||
{
|
||||
//lock for _finishedInitialization ?
|
||||
|
||||
_nonURLAttributeAssociations = nil;
|
||||
_urlAttributeAssociations = nil;
|
||||
NSMutableString * buffer = [NSMutableString stringWithCapacity:256];
|
||||
NSString * str = nil;
|
||||
NSString * s1 = nil;
|
||||
GSWAssociation * association = nil;
|
||||
id aValue = nil;
|
||||
int i = 0;
|
||||
|
||||
if ((_elementName != nil) && ((_associations != nil) && ([_associations count] > 0))) {
|
||||
NSEnumerator * enumer = [[NSArray arrayWithArray:[_associations allKeys]] objectEnumerator];
|
||||
|
||||
while ((str = [enumer nextObject])) {
|
||||
association = [_associations objectForKey: str];
|
||||
if (([association isKindOfClass:[GSWConstantValueAssociation class]]) && ([self escapeHTML] == NO)) {
|
||||
aValue = [association valueInComponent:nil];
|
||||
if (aValue == nil) {
|
||||
s1 = @"";
|
||||
} else {
|
||||
s1 = (NSString*)aValue;
|
||||
}
|
||||
if (!_finishedInitialization)
|
||||
{
|
||||
NSMutableString * buffer = nil;
|
||||
DESTROY(_nonURLAttributeAssociations);
|
||||
DESTROY(_urlAttributeAssociations);
|
||||
|
||||
if (_dynElementName != nil
|
||||
&& [_associations count] > 0)
|
||||
{
|
||||
IMP asIMP=NULL;
|
||||
BOOL escapeHTML=[self escapeHTML];
|
||||
NSEnumerator * enumer = [[NSArray arrayWithArray:[_associations allKeys]] objectEnumerator];
|
||||
NSString* key = nil;
|
||||
while ((key = [enumer nextObject]))
|
||||
{
|
||||
GSWAssociation* association = [_associations objectForKey: key];
|
||||
if ([association isKindOfClass:[GSWConstantValueAssociation class]]
|
||||
&& !escapeHTML)
|
||||
{
|
||||
NSString* aValue = [association valueInComponent:nil];
|
||||
if (aValue == nil)
|
||||
aValue = @"";
|
||||
else
|
||||
aValue = NSStringWithObject(aValue);
|
||||
|
||||
if ([s1 isKindOfClass:NSStringClass] == NO) {
|
||||
s1 = [(NSNumber*)s1 stringValue];
|
||||
}
|
||||
if ([aValue isEqual:@"otherTagString"]) {
|
||||
[buffer appendString:@" "];
|
||||
[buffer appendString: s1];
|
||||
} else {
|
||||
[buffer appendString:@" "];
|
||||
[buffer appendString: str];
|
||||
[buffer appendString:@"="];
|
||||
if (_needQuote(s1) || ([s1 length] == 0)) {
|
||||
[buffer appendString:@"\""];
|
||||
[buffer appendString: s1];
|
||||
[buffer appendString:@"\""];
|
||||
} else {
|
||||
[buffer appendString: s1];
|
||||
}
|
||||
}
|
||||
[_associations removeObjectForKey:str];
|
||||
} else {
|
||||
id resultattribute = [[self class] _urlAttributesForElementNamed:_elementName];
|
||||
BOOL flag = NO;
|
||||
NSString * lowercaseString = [str lowercaseString];
|
||||
if (resultattribute != nil)
|
||||
{
|
||||
if ([resultattribute isKindOfClass:NSStringClass] == NO) {
|
||||
int j = [resultattribute count];
|
||||
for (i = 0; ((i < j) && (!flag)); i++) {
|
||||
flag = [lowercaseString isEqual: [resultattribute objectAtIndex:i]];
|
||||
}
|
||||
} else { // is a string
|
||||
flag = [lowercaseString isEqual: resultattribute];
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
if (_urlAttributeAssociations == nil)
|
||||
{
|
||||
_urlAttributeAssociations = [NSMutableDictionary new];
|
||||
}
|
||||
[_urlAttributeAssociations setObject:association forKey:str];
|
||||
[_associations removeObjectForKey:str];
|
||||
}
|
||||
}
|
||||
} // while
|
||||
|
||||
if ([_associations count] > 0) {
|
||||
ASSIGN(_nonURLAttributeAssociations, _associations);
|
||||
if (buffer==nil)
|
||||
buffer=[NSMutableString stringWithCapacity:256];
|
||||
|
||||
if ([key isEqual:@"otherTagString"])
|
||||
{
|
||||
GSWeb_appendStringWithImpPtr(buffer,&asIMP,@" ");
|
||||
GSWeb_appendStringWithImpPtr(buffer,&asIMP,aValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWeb_appendStringWithImpPtr(buffer,&asIMP,@" ");
|
||||
GSWeb_appendStringWithImpPtr(buffer,&asIMP,key);
|
||||
GSWeb_appendStringWithImpPtr(buffer,&asIMP,@"=");
|
||||
if (_needQuote(aValue)
|
||||
|| [aValue length] == 0)
|
||||
{
|
||||
GSWeb_appendStringWithImpPtr(buffer,&asIMP,@"\"");
|
||||
GSWeb_appendStringWithImpPtr(buffer,&asIMP,aValue);
|
||||
GSWeb_appendStringWithImpPtr(buffer,&asIMP,@"\"");
|
||||
}
|
||||
else
|
||||
GSWeb_appendStringWithImpPtr(buffer,&asIMP,aValue);
|
||||
}
|
||||
[_associations removeObjectForKey:key];
|
||||
}
|
||||
else
|
||||
{
|
||||
id knowAttrKeys = [[self class] _urlAttributesForElementNamed:_dynElementName];
|
||||
BOOL isKnowURLAttr = NO;
|
||||
NSString * lcKey = [key lowercaseString];
|
||||
if (knowAttrKeys != nil)
|
||||
{
|
||||
if ([knowAttrKeys isKindOfClass:NSStringClass])
|
||||
{
|
||||
isKnowURLAttr = [lcKey isEqual: knowAttrKeys];
|
||||
}
|
||||
else
|
||||
{ // an array
|
||||
int c = [knowAttrKeys count];
|
||||
int i = 0;
|
||||
IMP oaiIMP=NULL;
|
||||
for (i = 0;i<c && !isKnowURLAttr; i++)
|
||||
{
|
||||
isKnowURLAttr = [lcKey isEqual: GSWeb_objectAtIndexWithImpPtr(knowAttrKeys,&oaiIMP,i)];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isKnowURLAttr)
|
||||
{
|
||||
if (_urlAttributeAssociations == nil)
|
||||
_urlAttributeAssociations = [NSMutableDictionary new];
|
||||
[_urlAttributeAssociations setObject:association
|
||||
forKey:lcKey];
|
||||
[_associations removeObjectForKey:lcKey];
|
||||
}
|
||||
}
|
||||
} // while
|
||||
|
||||
if ([_associations count] > 0)
|
||||
ASSIGN(_nonURLAttributeAssociations, _associations);
|
||||
}
|
||||
ASSIGN(_constantAttributesRepresentation,buffer);
|
||||
DESTROY(_associations);
|
||||
_finishedInitialization = YES;
|
||||
}
|
||||
}
|
||||
if ([buffer length] > 0) {
|
||||
ASSIGN(_constantAttributesRepresentation,buffer);
|
||||
} else {
|
||||
DESTROY(_constantAttributesRepresentation);
|
||||
}
|
||||
DESTROY(_associations);
|
||||
_finishedInitialization = YES;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)description
|
||||
{
|
||||
NSString * desStr = [NSString stringWithFormat:@"<%@ %p elementName:%@ ",
|
||||
[self class],
|
||||
(void*)self, _elementName];
|
||||
[self class],
|
||||
(void*)self, _dynElementName];
|
||||
|
||||
if (_constantAttributesRepresentation != nil) {
|
||||
if (_constantAttributesRepresentation != nil)
|
||||
desStr = [desStr stringByAppendingFormat:@" Constant Attributes: %@", _constantAttributesRepresentation];
|
||||
}
|
||||
if (_urlAttributeAssociations != nil) {
|
||||
|
||||
if (_urlAttributeAssociations != nil)
|
||||
desStr = [desStr stringByAppendingFormat:@" URL Dynamic Attributes: %@", _urlAttributeAssociations];
|
||||
}
|
||||
if (_nonURLAttributeAssociations != nil) {
|
||||
|
||||
if (_nonURLAttributeAssociations != nil)
|
||||
desStr = [desStr stringByAppendingFormat:@" non-URL Dynamic Attributes: %@", _nonURLAttributeAssociations];
|
||||
}
|
||||
if ([self hasChildrenElements]) {
|
||||
|
||||
if ([self hasChildrenElements])
|
||||
desStr = [desStr stringByAppendingFormat:@" Children: %@", [self childrenElements]];
|
||||
}
|
||||
|
||||
desStr = [desStr stringByAppendingString:@" >"];
|
||||
|
||||
return desStr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSString*) elementName
|
||||
{
|
||||
return _elementName;
|
||||
return _dynElementName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSMutableDictionary*) urlAttributeAssociations
|
||||
{
|
||||
if (!_finishedInitialization) {
|
||||
if (!_finishedInitialization)
|
||||
[self _finishInitialization];
|
||||
}
|
||||
return _urlAttributeAssociations;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSMutableDictionary*) nonUrlAttributeAssociations
|
||||
{
|
||||
if (!_finishedInitialization) {
|
||||
if (!_finishedInitialization)
|
||||
[self _finishInitialization];
|
||||
}
|
||||
return _nonURLAttributeAssociations;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSString*) constantAttributesRepresentation
|
||||
{
|
||||
if (!_finishedInitialization) {
|
||||
if (!_finishedInitialization)
|
||||
[self _finishInitialization];
|
||||
}
|
||||
return _constantAttributesRepresentation;
|
||||
|
||||
return _constantAttributesRepresentation;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// _frameworkNameInComponent
|
||||
+ (NSString*) _frameworkNameForAssociation: (GSWAssociation*)association
|
||||
inComponent: (GSWComponent *) component
|
||||
|
@ -320,16 +322,12 @@ static inline BOOL _needQuote(NSString* str_needQuote)
|
|||
if (name)
|
||||
{
|
||||
if ([@"app" caseInsensitiveCompare: name] == NSOrderedSame)
|
||||
{
|
||||
name = nil;
|
||||
}
|
||||
name = nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (component != nil)
|
||||
{
|
||||
name = [component frameworkName];
|
||||
}
|
||||
name = [component frameworkName];
|
||||
|
||||
[GSWApp debugWithFormat:@"%s evaluated to nil. Defaulting to %@",
|
||||
__PRETTY_FUNCTION__,
|
||||
|
@ -339,110 +337,117 @@ static inline BOOL _needQuote(NSString* str_needQuote)
|
|||
else
|
||||
{
|
||||
if (component != nil)
|
||||
{
|
||||
name = [component frameworkName];
|
||||
}
|
||||
name = [component frameworkName];
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
// computeActionStringInContext in wo5
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)computeActionStringWithActionClassAssociation:(GSWAssociation*)actionClass
|
||||
directActionNameAssociation:(GSWAssociation*)directActionName
|
||||
inContext:(GSWContext*)context
|
||||
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
id componentValue = nil;
|
||||
id directActionValue = nil;
|
||||
id resultString = nil;
|
||||
NSString* actionClassValue = nil;
|
||||
NSString* directActionValue = nil;
|
||||
NSString* resultString = nil;
|
||||
|
||||
if (actionClass != nil) {
|
||||
componentValue = [actionClass valueInComponent: component];
|
||||
if ([componentValue isKindOfClass: NSStringClass] == NO) {
|
||||
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Value for attribute named '%@' must be a string. Received '%@'.",
|
||||
__PRETTY_FUNCTION__, actionClass, componentValue];
|
||||
if (actionClass != nil)
|
||||
{
|
||||
actionClassValue = [actionClass valueInComponent: component];
|
||||
if ([actionClassValue isKindOfClass: NSStringClass] == NO)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Value for attribute named '%@' must be a string. Received '%@'.",
|
||||
__PRETTY_FUNCTION__, actionClass, actionClassValue];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (directActionName != nil)
|
||||
{
|
||||
directActionValue = [directActionName valueInComponent:component];
|
||||
if ([directActionValue isKindOfClass: NSStringClass] == NO) {
|
||||
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Value for attribute named '%@' must be a string. Received '%@'.",
|
||||
__PRETTY_FUNCTION__, directActionName, directActionValue];
|
||||
|
||||
{
|
||||
directActionValue = [directActionName valueInComponent:component];
|
||||
if ([directActionValue isKindOfClass: NSStringClass] == NO)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Value for attribute named '%@' must be a string. Received '%@'.",
|
||||
__PRETTY_FUNCTION__, directActionName, directActionValue];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((componentValue != nil) && (directActionValue != nil)) {
|
||||
if ([componentValue isEqual:@"DirectAction"]) {
|
||||
resultString = directActionValue;
|
||||
} else {
|
||||
resultString = [componentValue stringByAppendingString:@"/"];
|
||||
resultString = [resultString stringByAppendingString:directActionValue];
|
||||
if (actionClassValue != nil
|
||||
&& directActionValue != nil)
|
||||
{
|
||||
if ([actionClassValue isEqual:@"DirectAction"])
|
||||
resultString = directActionValue;
|
||||
else
|
||||
{
|
||||
resultString = [actionClassValue stringByAppendingString:@"/"];
|
||||
resultString = [resultString stringByAppendingString:directActionValue];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (componentValue != nil) {
|
||||
resultString = componentValue;
|
||||
} else {
|
||||
if (directActionValue != nil) {
|
||||
resultString = directActionValue;
|
||||
} else {
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s: Both 'actionClass' and 'directActionName' are either absent or evaluated to nil. Cannot generate dynamic url without an actionClass or directActionName.",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
else if (actionClassValue != nil)
|
||||
resultString = actionClassValue;
|
||||
else if (directActionValue != nil)
|
||||
resultString = directActionValue;
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s: Both 'actionClass' and 'directActionName' are either absent or evaluated to nil. Cannot generate dynamic url without an actionClass or directActionName.",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
}
|
||||
|
||||
return resultString;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSDictionary*) __queryDictionary:(GSWAssociation*) queryDictionary
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
NSDictionary* aQueryDict = nil;
|
||||
|
||||
if (queryDictionary != nil) {
|
||||
if (queryDictionary != nil)
|
||||
aQueryDict = [queryDictionary valueInComponent:[context component]];
|
||||
}
|
||||
|
||||
if(aQueryDict != nil) {
|
||||
if(aQueryDict != nil)
|
||||
return aQueryDict;
|
||||
} else {
|
||||
// or a nil? -- dw
|
||||
return [NSDictionary dictionary];
|
||||
}
|
||||
else
|
||||
return [NSDictionary dictionary]; // or a nil? -- dw
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSDictionary*) __otherQueryDictionary:(NSDictionary*) otherQueryAssociations
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
NSMutableDictionary * queryDict = [NSMutableDictionary dictionary];
|
||||
NSMutableDictionary * queryDict = nil;
|
||||
|
||||
if (otherQueryAssociations != nil) {
|
||||
NSEnumerator *keyEnumerator = [otherQueryAssociations keyEnumerator];
|
||||
NSString *key;
|
||||
if (otherQueryAssociations != nil)
|
||||
{
|
||||
NSEnumerator *keyEnumerator = [otherQueryAssociations keyEnumerator];
|
||||
NSString *key = nil;
|
||||
|
||||
while ((key = [keyEnumerator nextObject]))
|
||||
{
|
||||
GSWAssociation * association = [otherQueryAssociations objectForKey:key];
|
||||
id value = [association valueInComponent:[context component]];
|
||||
|
||||
while ((key = [keyEnumerator nextObject])) {
|
||||
GSWAssociation * association = [otherQueryAssociations objectForKey:key];
|
||||
id value = [association valueInComponent:[context component]];
|
||||
|
||||
if (value) {
|
||||
[queryDict setObject:value forKey:key];
|
||||
}
|
||||
}
|
||||
if (value)
|
||||
{
|
||||
if (!queryDict)
|
||||
queryDict=[NSMutableDictionary dictionary];
|
||||
[queryDict setObject:value
|
||||
forKey:key];
|
||||
}
|
||||
}
|
||||
}
|
||||
// is it really faster/better to copy this here? -- dw
|
||||
return [NSDictionary dictionaryWithDictionary:queryDict];
|
||||
return (queryDict==nil ? [NSDictionary dictionary] : [NSDictionary dictionaryWithDictionary:queryDict]);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSDictionary*) computeQueryDictionaryWithRequestHandlerPath: (NSString*) aRequestHandlerPath
|
||||
queryDictionaryAssociation: (GSWAssociation*) queryDictionary
|
||||
otherQueryAssociations: (NSDictionary*) otherQueryAssociations
|
||||
|
@ -462,6 +467,7 @@ static inline BOOL _needQuote(NSString* str_needQuote)
|
|||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSDictionary*) computeQueryDictionaryWithActionClassAssociation: (GSWAssociation*)actionClass
|
||||
directActionNameAssociation: (GSWAssociation*)directActionName
|
||||
queryDictionaryAssociation: (GSWAssociation*)queryDictionary
|
||||
|
@ -503,22 +509,19 @@ static inline BOOL _needQuote(NSString* str_needQuote)
|
|||
|
||||
if (otherQueryAssociations != nil)
|
||||
{
|
||||
GSWAssociation *otherAssociations = nil;
|
||||
NSString * key = nil;
|
||||
id otherValue = nil;
|
||||
NSEnumerator* keyEnumerator = [otherQueryAssociations keyEnumerator];
|
||||
|
||||
while ((key = [keyEnumerator nextObject]))
|
||||
{
|
||||
otherAssociations = [otherQueryAssociations objectForKey:key];
|
||||
otherValue = [otherAssociations valueInComponent:component];
|
||||
GSWAssociation* otherAssociations = [otherQueryAssociations objectForKey:key];
|
||||
id otherValue = [otherAssociations valueInComponent:component];
|
||||
if (otherValue != nil)
|
||||
{
|
||||
if ([key isEqual:GSWKey_SessionID[GSWebNamingConv]]
|
||||
|| [key isEqual:[GSWApp sessionIdKey]])
|
||||
{
|
||||
if ([otherValue isKindOfClass:[NSNumber class]]
|
||||
&& [otherValue boolValue] == NO)
|
||||
if (GSWIsBoolNumberNo(otherValue))
|
||||
[newQueryDictionary removeObjectForKey:key];
|
||||
}
|
||||
else
|
||||
|
@ -536,15 +539,16 @@ static inline BOOL _needQuote(NSString* str_needQuote)
|
|||
return newQueryDictionary;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendConstantAttributesToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
NSString * str = [self constantAttributesRepresentation];
|
||||
if (str != nil) {
|
||||
if (str != nil)
|
||||
GSWResponse_appendContentString(response,str);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendAttributesFromAssociationsToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*)context
|
||||
associations:(NSDictionary*) associations
|
||||
|
@ -553,36 +557,32 @@ static inline BOOL _needQuote(NSString* str_needQuote)
|
|||
if (associations != nil
|
||||
&& [associations count] > 0)
|
||||
{
|
||||
NSString * s1 = nil;
|
||||
NSEnumerator * enumer = [associations keyEnumerator];
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
NSString * key = nil;
|
||||
GSWAssociation * currentAssociation = nil;
|
||||
id obj = nil;
|
||||
|
||||
while ((key = [enumer nextObject]))
|
||||
{
|
||||
currentAssociation = [associations objectForKey:key];
|
||||
obj = [currentAssociation valueInComponent:component];
|
||||
if (obj != nil)
|
||||
GSWAssociation* currentAssociation = [associations objectForKey:key];
|
||||
NSString* value = [currentAssociation valueInComponent:component];
|
||||
if (value != nil)
|
||||
{
|
||||
s1=NSStringWithObject(obj);
|
||||
value=NSStringWithObject(value);
|
||||
if ([key isEqual:@"otherTagString"])
|
||||
{
|
||||
GSWResponse_appendContentCharacter(response,' ');
|
||||
GSWResponse_appendContentString(response, s1);
|
||||
GSWResponse_appendContentString(response, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
[response _appendTagAttribute: key
|
||||
value: s1
|
||||
escapingHTMLAttributeValue: NO];
|
||||
{
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,key,value,NO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendNonURLAttributesToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
|
||||
|
@ -593,50 +593,52 @@ static inline BOOL _needQuote(NSString* str_needQuote)
|
|||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendURLAttributesToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
GSWComponent * component = nil;
|
||||
NSMutableDictionary * attributeDict = [self urlAttributeAssociations];
|
||||
GSWAssociation * association = nil;
|
||||
id value = nil;
|
||||
|
||||
if ((attributeDict != nil) && ([attributeDict count] > 0)) {
|
||||
component = GSWContext_component(context);
|
||||
NSEnumerator * enumer = [attributeDict keyEnumerator];
|
||||
if ([attributeDict count] > 0)
|
||||
{
|
||||
GSWComponent* component = GSWContext_component(context);
|
||||
NSEnumerator* enumer = [attributeDict keyEnumerator];
|
||||
NSString * key = nil;
|
||||
|
||||
NSString * key = nil;
|
||||
|
||||
NSString * s1 = nil;
|
||||
|
||||
while ((key = [enumer nextObject])) {
|
||||
association = [attributeDict objectForKey:key];
|
||||
value = [association valueInComponent:component];
|
||||
if (value != nil) {
|
||||
// value to string??
|
||||
s1 = [context _urlForResourceNamed: value
|
||||
inFramework: nil];
|
||||
} else {
|
||||
[GSWApp debugWithFormat:@"%s evaluated to nil in component %@. Inserted nil resource in html tag.",
|
||||
__PRETTY_FUNCTION__, component];
|
||||
}
|
||||
if (s1 != nil) {
|
||||
[response _appendTagAttribute: key
|
||||
value: s1
|
||||
escapingHTMLAttributeValue: NO];
|
||||
} else {
|
||||
GSWResponse_appendContentCharacter(response,' ');
|
||||
GSWResponse_appendContentString(response, key);
|
||||
GSWResponse_appendContentAsciiString(response,@"=\"");
|
||||
GSWResponse_appendContentAsciiString(response, [component baseURL]);
|
||||
GSWResponse_appendContentCharacter(response,'/');
|
||||
GSWResponse_appendContentAsciiString(response, value);
|
||||
GSWResponse_appendContentCharacter(response,'"');
|
||||
}
|
||||
while ((key = [enumer nextObject]))
|
||||
{
|
||||
GSWAssociation* association = [attributeDict objectForKey:key];
|
||||
NSString* value = NSStringWithObject([association valueInComponent:component]);
|
||||
NSString* urlValue=nil;
|
||||
if (value != nil)
|
||||
{
|
||||
urlValue = [context _urlForResourceNamed: value
|
||||
inFramework: nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
[GSWApp debugWithFormat:@"%s evaluated to nil in component %@. Inserted nil resource in html tag.",
|
||||
__PRETTY_FUNCTION__, component];
|
||||
}
|
||||
if (urlValue != nil)
|
||||
{
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,key,urlValue,NO);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWResponse_appendContentCharacter(response,' ');
|
||||
GSWResponse_appendContentString(response, key);
|
||||
GSWResponse_appendContentAsciiString(response,@"=\"");
|
||||
GSWResponse_appendContentAsciiString(response, [component baseURL]);
|
||||
GSWResponse_appendContentCharacter(response,'/');
|
||||
GSWResponse_appendContentAsciiString(response, value);
|
||||
GSWResponse_appendContentCharacter(response,'"');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendAttributesToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -650,16 +652,19 @@ static inline BOOL _needQuote(NSString* str_needQuote)
|
|||
inContext: context];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendOpenTagToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
|
||||
{
|
||||
GSWResponse_appendContentCharacter(response,'<');
|
||||
GSWResponse_appendContentAsciiString(response, [self elementName]);
|
||||
[self appendAttributesToResponse:response inContext: context];
|
||||
[self appendAttributesToResponse:response
|
||||
inContext: context];
|
||||
GSWResponse_appendContentCharacter(response,'>');
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendCloseTagToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -668,36 +673,38 @@ static inline BOOL _needQuote(NSString* str_needQuote)
|
|||
GSWResponse_appendContentCharacter(response,'>');
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
NSString * myElementName = nil;
|
||||
|
||||
if (context == nil || response == nil) {
|
||||
return;
|
||||
}
|
||||
myElementName = [self elementName];
|
||||
if (myElementName != nil) {
|
||||
[self _appendOpenTagToResponse:response
|
||||
inContext: context];
|
||||
}
|
||||
if (context != nil
|
||||
&& response != nil)
|
||||
{
|
||||
NSString * myElementName = [self elementName];
|
||||
if (myElementName != nil)
|
||||
{
|
||||
[self _appendOpenTagToResponse:response
|
||||
inContext: context];
|
||||
}
|
||||
|
||||
[self appendChildrenToResponse: response
|
||||
inContext: context];
|
||||
|
||||
[self appendChildrenToResponse: response
|
||||
inContext: context];
|
||||
|
||||
if (myElementName != nil) {
|
||||
[self _appendCloseTagToResponse:response
|
||||
inContext: context];
|
||||
}
|
||||
if (myElementName != nil)
|
||||
{
|
||||
[self _appendCloseTagToResponse:response
|
||||
inContext: context];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (BOOL) secureInContext:(GSWContext*) context
|
||||
{
|
||||
if (_secure != nil) {
|
||||
if (_secure != nil)
|
||||
return [_secure boolValueInComponent:[context component]];
|
||||
} else {
|
||||
else
|
||||
return [context secureMode];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
#include <GNUstepBase/NSObject+GNUstepBase.h>
|
||||
|
||||
/*
|
||||
|
@ -42,7 +43,6 @@ In WO 4.5 WOHTMLStaticElement.
|
|||
*/
|
||||
|
||||
|
||||
static SEL objectAtIndexSEL = NULL;
|
||||
static GSWIMP_BOOL standardEvaluateConditionInContextIMP = NULL;
|
||||
|
||||
static Class standardClass = Nil;
|
||||
|
@ -58,7 +58,6 @@ static Class GSWHTMLBareStringClass = Nil;
|
|||
{
|
||||
standardClass=[GSWHTMLStaticElement class];
|
||||
GSWHTMLBareStringClass = [GSWHTMLBareString class];
|
||||
objectAtIndexSEL=@selector(objectAtIndex:);
|
||||
|
||||
standardEvaluateConditionInContextIMP =
|
||||
(GSWIMP_BOOL)[self instanceMethodForSelector:evaluateConditionInContextSEL];
|
||||
|
@ -207,6 +206,7 @@ static Class GSWHTMLBareStringClass = Nil;
|
|||
NSMutableArray* rmStrings=[NSMutableArray array];
|
||||
NSMutableString* rmString=[[NSMutableString new] autorelease];
|
||||
NSMutableData* tmpElementsMap=[[NSMutableData new] autorelease];
|
||||
IMP oaiIMP=NULL;
|
||||
[tmpElementsMap appendBytes:&ElementsMap_htmlBareString
|
||||
length:1];
|
||||
if ([tmpElementsMap length]>elementN)
|
||||
|
@ -216,14 +216,14 @@ static Class GSWHTMLBareStringClass = Nil;
|
|||
[tmpElementsMap length]-elementN)]];
|
||||
for(rmStringN=0;rmStringN<elementN;rmStringN++)
|
||||
{
|
||||
[rmString appendString:[tmpHtmlBareStrings objectAtIndex:rmStringN]];
|
||||
[rmString appendString:GSWeb_objectAtIndexWithImpPtr(tmpHtmlBareStrings,&oaiIMP,rmStringN)];
|
||||
};
|
||||
[rmStrings addObject:rmString];
|
||||
|
||||
tmpHtmlBareStringsCount=[tmpHtmlBareStrings count];
|
||||
for(rmStringN=elementN;rmStringN<tmpHtmlBareStringsCount;rmStringN++)
|
||||
{
|
||||
[rmStrings addObject:[tmpHtmlBareStrings objectAtIndex:rmStringN]];
|
||||
[rmStrings addObject:GSWeb_objectAtIndexWithImpPtr(tmpHtmlBareStrings,&oaiIMP,rmStringN)];
|
||||
};
|
||||
tmpHtmlBareStrings=rmStrings;
|
||||
};
|
||||
|
@ -310,16 +310,17 @@ static Class GSWHTMLBareStringClass = Nil;
|
|||
// GSWSaveAppendToResponseElementID(aContext);
|
||||
|
||||
length=[_elementsMap length];
|
||||
[aContext appendZeroElementIDComponent];
|
||||
GSWContext_appendZeroElementIDComponent(aContext);
|
||||
|
||||
if (length>0) {
|
||||
[self appendToResponse:response
|
||||
inContext:aContext
|
||||
elementsFromIndex:0
|
||||
toIndex:length-1];
|
||||
};
|
||||
if (length>0)
|
||||
{
|
||||
[self appendToResponse:response
|
||||
inContext:aContext
|
||||
elementsFromIndex:0
|
||||
toIndex:length-1];
|
||||
};
|
||||
|
||||
[aContext deleteLastElementIDComponent];
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
|
||||
// GSWAssertIsElementID(aContext);
|
||||
// GSWStopElement(aContext);
|
||||
|
@ -331,13 +332,13 @@ static Class GSWHTMLBareStringClass = Nil;
|
|||
elementsFromIndex:(unsigned int)fromIndex
|
||||
toIndex:(unsigned int)toIndex
|
||||
{
|
||||
IMP htmlBareStringsObjectAtIndexIMP=NULL;
|
||||
IMP objectAtIndexIMP = NULL;
|
||||
NSArray* aDynamicChildrensArray=[self dynamicChildren];//call dynamicChildren //GSWTextField: nil
|
||||
int elementN=0;
|
||||
const BYTE* elements=[_elementsMap bytes];
|
||||
BYTE element=0;
|
||||
int elementsN[3]={0,0,0};
|
||||
IMP hbs_oaiIMP=NULL;
|
||||
IMP adca_oaiIMP=NULL;
|
||||
|
||||
NSAssert2(fromIndex<[_elementsMap length],@"fromIndex out of range:%u (length=%"PRIuPTR")",
|
||||
fromIndex,[_elementsMap length]);
|
||||
|
@ -353,13 +354,8 @@ static Class GSWHTMLBareStringClass = Nil;
|
|||
{
|
||||
if (elementN>=fromIndex)
|
||||
{
|
||||
if (!htmlBareStringsObjectAtIndexIMP)
|
||||
htmlBareStringsObjectAtIndexIMP = [_htmlBareStrings methodForSelector:objectAtIndexSEL];
|
||||
|
||||
GSWResponse_appendContentString(aResponse,
|
||||
((*htmlBareStringsObjectAtIndexIMP)(_htmlBareStrings,
|
||||
objectAtIndexSEL,
|
||||
elementsN[0])));
|
||||
GSWeb_objectAtIndexWithImpPtr(_htmlBareStrings,&hbs_oaiIMP,elementsN[0]));
|
||||
};
|
||||
|
||||
elementsN[0]++;
|
||||
|
@ -368,12 +364,9 @@ static Class GSWHTMLBareStringClass = Nil;
|
|||
{
|
||||
if (elementN>=fromIndex)
|
||||
{
|
||||
if (!objectAtIndexIMP)
|
||||
objectAtIndexIMP = [aDynamicChildrensArray methodForSelector:objectAtIndexSEL];
|
||||
|
||||
[(*objectAtIndexIMP)(aDynamicChildrensArray,objectAtIndexSEL,elementsN[1])
|
||||
appendToResponse:aResponse
|
||||
inContext:aContext];
|
||||
[GSWeb_objectAtIndexWithImpPtr(aDynamicChildrensArray,&adca_oaiIMP,elementsN[1])
|
||||
appendToResponse:aResponse
|
||||
inContext:aContext];
|
||||
|
||||
GSWContext_incrementLastElementIDComponent(aContext);
|
||||
|
||||
|
@ -404,49 +397,44 @@ static Class GSWHTMLBareStringClass = Nil;
|
|||
|
||||
length=[_elementsMap length];
|
||||
|
||||
if ([self hasChildrenElements]) {
|
||||
IMP objectAtIndexIMP = NULL;
|
||||
if ([self hasChildrenElements])
|
||||
{
|
||||
NSArray* aDynamicChildrensArray=[self dynamicChildren];
|
||||
const BYTE* elements=[_elementsMap bytes];
|
||||
BYTE elementIndic=0;
|
||||
int elementsN[3]={0,0,0};
|
||||
int elementN=0;
|
||||
IMP adca_oaiIMP=NULL;
|
||||
|
||||
id currentEl = nil;
|
||||
|
||||
[aContext appendZeroElementIDComponent];
|
||||
GSWContext_appendZeroElementIDComponent(aContext);
|
||||
|
||||
for(elementN=0;!element && !searchIsOver && elementN<length;elementN++)
|
||||
{
|
||||
elementIndic=(BYTE)elements[elementN];
|
||||
BYTE elementIndic=(BYTE)elements[elementN];
|
||||
if (elementIndic==ElementsMap_htmlBareString)
|
||||
elementsN[0]++;
|
||||
else if (elementIndic==ElementsMap_dynamicElement)
|
||||
{
|
||||
if (!objectAtIndexIMP)
|
||||
objectAtIndexIMP = [aDynamicChildrensArray methodForSelector:objectAtIndexSEL];
|
||||
|
||||
currentEl = (*objectAtIndexIMP)(aDynamicChildrensArray,objectAtIndexSEL,elementsN[1]);
|
||||
if ([currentEl class] != GSWHTMLBareStringClass) {
|
||||
|
||||
element = (id <GSWActionResults, NSObject>) [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))
|
||||
id currentEl = GSWeb_objectAtIndexWithImpPtr(aDynamicChildrensArray,&adca_oaiIMP,elementsN[1]);
|
||||
if ([currentEl class] != GSWHTMLBareStringClass)
|
||||
{
|
||||
element = (id <GSWActionResults, NSObject>) [currentEl invokeActionForRequest:request
|
||||
inContext:aContext];
|
||||
|
||||
NSAssert3(!element || [element isKindOfClass:[GSWElement class]],
|
||||
@"From: %@, Element is a %@ not a GSWElement: %@",
|
||||
currentEl,
|
||||
[element class],
|
||||
element);
|
||||
}
|
||||
// TODO: check if that is right.
|
||||
// if (![aContext _wasFormSubmitted] && GSWContext_isSenderIDSearchOver(aContext))
|
||||
if (![aContext _wasFormSubmitted] && (element))
|
||||
{
|
||||
searchIsOver=YES;
|
||||
};
|
||||
|
||||
|
||||
GSWContext_incrementLastElementIDComponent(aContext);
|
||||
|
||||
|
||||
elementsN[1]++;
|
||||
}
|
||||
else if (elementIndic==ElementsMap_attributeElement)
|
||||
|
@ -454,7 +442,7 @@ id currentEl = nil;
|
|||
elementsN[2]++;
|
||||
};
|
||||
};
|
||||
[aContext deleteLastElementIDComponent];
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
};
|
||||
|
||||
return element;
|
||||
|
@ -472,28 +460,24 @@ id currentEl = nil;
|
|||
length=[_elementsMap length];
|
||||
if ([self hasChildrenElements]) {
|
||||
|
||||
IMP objectAtIndexIMP = NULL;
|
||||
int elementN=0;
|
||||
NSArray* aDynamicChildrensArray=[self dynamicChildren];
|
||||
const BYTE* elements=[_elementsMap bytes];
|
||||
BYTE elementIndic=0;
|
||||
int elementsN[3]={0,0,0};
|
||||
IMP adca_oaiIMP=NULL;
|
||||
|
||||
[aContext appendZeroElementIDComponent];
|
||||
GSWContext_appendZeroElementIDComponent(aContext);
|
||||
|
||||
for(elementN=0;elementN<length;elementN++)
|
||||
{
|
||||
elementIndic=(BYTE)elements[elementN];
|
||||
BYTE elementIndic=(BYTE)elements[elementN];
|
||||
if (elementIndic==ElementsMap_htmlBareString)
|
||||
elementsN[0]++;
|
||||
else if (elementIndic==ElementsMap_dynamicElement)
|
||||
{
|
||||
if (!objectAtIndexIMP)
|
||||
objectAtIndexIMP = [aDynamicChildrensArray methodForSelector:objectAtIndexSEL];
|
||||
|
||||
[(*objectAtIndexIMP)(aDynamicChildrensArray,objectAtIndexSEL,elementsN[1])
|
||||
takeValuesFromRequest:request
|
||||
inContext:aContext];
|
||||
[GSWeb_objectAtIndexWithImpPtr(aDynamicChildrensArray,&adca_oaiIMP,elementsN[1])
|
||||
takeValuesFromRequest:request
|
||||
inContext:aContext];
|
||||
|
||||
GSWContext_incrementLastElementIDComponent(aContext);
|
||||
|
||||
|
@ -504,7 +488,7 @@ id currentEl = nil;
|
|||
elementsN[2]++;
|
||||
};
|
||||
};
|
||||
[aContext deleteLastElementIDComponent];
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
};
|
||||
GSWAssertIsElementID(aContext);
|
||||
GSWStopElement(aContext);
|
||||
|
|
|
@ -56,9 +56,6 @@
|
|||
-(NSString*)valueAttributeName;
|
||||
-(NSString*)urlAttributeName;
|
||||
|
||||
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
|
||||
inContext:(GSWContext*)aContext;
|
||||
|
||||
@end
|
||||
|
||||
#endif // _GSWHTMLURLValuedElement_h__
|
||||
|
|
|
@ -37,121 +37,91 @@ RCS_ID("$Id$")
|
|||
//====================================================================
|
||||
@implementation GSWHTMLURLValuedElement
|
||||
|
||||
-(NSString*) valueAttributeName
|
||||
{
|
||||
return @"src";
|
||||
}
|
||||
|
||||
-(NSString*) urlAttributeName
|
||||
{
|
||||
return @"value";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
NSString* urlAttributeName=nil;
|
||||
NSString* valueAttributeName=nil;
|
||||
if ((self=[super initWithName: aName
|
||||
associations:associations
|
||||
template:template]))
|
||||
{
|
||||
NSString* urlAttributeName = [self urlAttributeName];
|
||||
NSString* valueAttributeName = [self valueAttributeName];
|
||||
|
||||
self=[super initWithName: aName
|
||||
associations:associations
|
||||
template:template];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
urlAttributeName = [self urlAttributeName];
|
||||
valueAttributeName = [self valueAttributeName];
|
||||
GSWAssignAndRemoveAssociation(&_src,_associations,urlAttributeName);
|
||||
GSWAssignAndRemoveAssociation(&_value,_associations,valueAttributeName);
|
||||
GSWAssignAndRemoveAssociation(&_pageName,_associations,pageName__Key);
|
||||
GSWAssignAndRemoveAssociation(&_filename,_associations,filename__Key);
|
||||
GSWAssignAndRemoveAssociation(&_framework,_associations,framework__Key);
|
||||
GSWAssignAndRemoveAssociation(&_data,_associations,data__Key);
|
||||
GSWAssignAndRemoveAssociation(&_mimeType,_associations,mimeType__Key);
|
||||
GSWAssignAndRemoveAssociation(&_key,_associations,key__Key);
|
||||
GSWAssignAndRemoveAssociation(&_queryDictionary,_associations,queryDictionary__Key);
|
||||
GSWAssignAndRemoveAssociation(&_actionClass,_associations,actionClass__Key);
|
||||
GSWAssignAndRemoveAssociation(&_directActionName,_associations,directActionName__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];
|
||||
}
|
||||
|
||||
_otherQueryAssociations = RETAIN([_associations extractObjectsForKeysWithPrefix:@"?"
|
||||
removePrefix: YES]);
|
||||
_otherQueryAssociations = RETAIN([_associations extractObjectsForKeysWithPrefix:@"?"
|
||||
removePrefix: YES]);
|
||||
|
||||
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 (_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]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
@ -185,37 +155,52 @@ RCS_ID("$Id$")
|
|||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
|
||||
-(NSString*) valueAttributeName
|
||||
{
|
||||
return @"src";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*) urlAttributeName
|
||||
{
|
||||
return @"value";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id <GSWActionResults>)invokeActionForRequest:(GSWRequest*)aRequest
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
id <GSWActionResults, NSObject> element = nil;
|
||||
NSString* senderID = nil;
|
||||
NSString* elementID = nil;
|
||||
GSWComponent * component = nil;
|
||||
id <GSWActionResults> element = nil;
|
||||
|
||||
NSString* elementID = GSWContext_elementID(context);
|
||||
NSString* senderID = GSWContext_senderID(context);
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (elementID != nil
|
||||
&& senderID != nil
|
||||
&& [elementID isEqual:senderID])
|
||||
{
|
||||
GSWComponent* component = GSWContext_component(context);
|
||||
if (_value != nil)
|
||||
element = [_value valueInComponent:component];
|
||||
else if (_pageName != nil)
|
||||
{
|
||||
NSString* pageName = NSStringWithObject([_pageName valueInComponent:component]);
|
||||
if (pageName != nil)
|
||||
{
|
||||
element = [GSWApp pageWithName:pageName
|
||||
inContext:context];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
element = [super invokeActionForRequest: aRequest
|
||||
inContext: context];
|
||||
}
|
||||
} else {
|
||||
element = (id <GSWActionResults, NSObject>) [super invokeActionForRequest: aRequest inContext: context];
|
||||
}
|
||||
return element;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSString*) _imageURL:(GSWContext*) context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
|
@ -225,26 +210,27 @@ RCS_ID("$Id$")
|
|||
NSString * url = [context _urlForResourceNamed: fname
|
||||
inFramework: fwname];
|
||||
|
||||
if (url == nil) {
|
||||
url = [[GSWApp resourceManager] errorMessageUrlForResourceNamed:fname inFramework:fwname];
|
||||
}
|
||||
if (url == nil)
|
||||
{
|
||||
url = [[GSWApp resourceManager] errorMessageUrlForResourceNamed:fname
|
||||
inFramework:fwname];
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (void) _appendFilenameToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
NSString * myurl = [self _imageURL:context];
|
||||
|
||||
[response _appendTagAttribute: [self urlAttributeName]
|
||||
value: myurl
|
||||
escapingHTMLAttributeValue: NO];
|
||||
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
[self urlAttributeName],
|
||||
[self _imageURL:context],
|
||||
NO);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSString*) CGIActionURL:(GSWContext*) context
|
||||
{
|
||||
|
||||
NSString * actionString = [self computeActionStringWithActionClassAssociation: _actionClass
|
||||
directActionNameAssociation: _directActionName
|
||||
inContext: context];
|
||||
|
@ -257,72 +243,86 @@ RCS_ID("$Id$")
|
|||
|
||||
return [context directActionURLForActionNamed: actionString
|
||||
queryDictionary: queryDict];
|
||||
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (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 {
|
||||
|
||||
if (_directActionName != nil || _actionClass != nil)
|
||||
{
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
[self urlAttributeName],
|
||||
[self CGIActionURL:context],
|
||||
NO);
|
||||
}
|
||||
else if (_filename != nil)
|
||||
{
|
||||
[self _appendFilenameToResponse:response
|
||||
inContext:context];
|
||||
}
|
||||
else if (_value != nil || _pageName != nil)
|
||||
{
|
||||
GSWComponent* component = GSWContext_component(context);
|
||||
BOOL secure = (_secure != nil ? [_secure boolValueInComponent:component] : NO);
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
[self urlAttributeName],
|
||||
[context _componentActionURLIsSecure:secure],
|
||||
NO);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSWComponent* component = GSWContext_component(context);
|
||||
NSString* src=NSStringWithObject([_src valueInComponent:component]);
|
||||
if (src != nil)
|
||||
{
|
||||
if ([src isRelativeURL]
|
||||
&& ![src isFragmentURL])
|
||||
{
|
||||
NSString* url = [context _urlForResourceNamed: src
|
||||
inFramework: nil];
|
||||
if (url != nil)
|
||||
{
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
[self urlAttributeName],
|
||||
url,
|
||||
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
|
||||
{
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
[self urlAttributeName],
|
||||
src,
|
||||
NO);
|
||||
}
|
||||
} else
|
||||
if (_data != nil && _mimeType != nil)
|
||||
{
|
||||
// TODO call _appendDataURLAttributeToResponse
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: you need to add a call to _appendDataURLAttributeToResponse in file '%s'",
|
||||
__PRETTY_FUNCTION__,__FILE__];
|
||||
|
||||
}
|
||||
}
|
||||
else if (_data != nil && _mimeType != nil)
|
||||
{
|
||||
[GSWURLValuedElementData _appendDataURLAttributeToResponse:response
|
||||
inContext:context
|
||||
key:_key
|
||||
data:_data
|
||||
mimeType:_mimeType
|
||||
urlAttributeName:[self urlAttributeName]
|
||||
inComponent:component];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "GSWResponse.h"
|
||||
#include "GSWRequest.h"
|
||||
#include "GSWApplication.h"
|
||||
#include "GSWPrivate.h"
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
@ -170,47 +171,58 @@ void _unpackHeaderLineAddToDict(NSString *line, NSMutableDictionary* headers)
|
|||
|
||||
//PRIVATE
|
||||
|
||||
void _appendMessageHeaders(GSWResponse * message,NSMutableString * headers)
|
||||
void _appendMessageHeaders(GSWResponse * message,NSMutableString * headers, IMP* headersAppStringIMPPtr)
|
||||
{
|
||||
NSMutableDictionary * headerDict = [message headers];
|
||||
NSArray * keyArray = nil;
|
||||
int i = 0;
|
||||
|
||||
if (headerDict != nil) {
|
||||
int count = 0;
|
||||
if (![headerDict isKindOfClass:[NSMutableDictionary class]]) {
|
||||
headerDict = [[headerDict mutableCopy] autorelease];
|
||||
}
|
||||
[headerDict removeObjectForKey:GSWHTTPHeader_ContentLength];
|
||||
keyArray = [headerDict allKeys];
|
||||
count = [keyArray count];
|
||||
|
||||
for (; i < count; i++) {
|
||||
NSString * currentKey = [keyArray objectAtIndex:i];
|
||||
NSArray * currentValueArray = [headerDict objectForKey:currentKey];
|
||||
if ([currentValueArray isKindOfClass:[NSArray class]]) {
|
||||
int x = 0;
|
||||
int valueCount = [currentValueArray count];
|
||||
for (; x < valueCount; x++) {
|
||||
[headers appendString:currentKey];
|
||||
[headers appendString:HEADERSEP];
|
||||
[headers appendString:[currentValueArray objectAtIndex:x]];
|
||||
[headers appendString:NEWLINE];
|
||||
}
|
||||
} else {
|
||||
NSString * myStrValue = (NSString*) currentValueArray;
|
||||
[headers appendString:currentKey];
|
||||
[headers appendString:HEADERSEP];
|
||||
[headers appendString:myStrValue];
|
||||
[headers appendString:NEWLINE];
|
||||
}
|
||||
}
|
||||
if (headerDict != nil)
|
||||
{
|
||||
NSUInteger count = 0;
|
||||
IMP keyArray_oaiIMP=NULL;
|
||||
if (![headerDict isKindOfClass:[NSMutableDictionary class]])
|
||||
headerDict = [[headerDict mutableCopy] autorelease];
|
||||
|
||||
}
|
||||
[headerDict removeObjectForKey:GSWHTTPHeader_ContentLength];
|
||||
keyArray = [headerDict allKeys];
|
||||
count = [keyArray count];
|
||||
|
||||
for (; i < count; i++)
|
||||
{
|
||||
NSString * currentKey = GSWeb_objectAtIndexWithImpPtr(keyArray,&keyArray_oaiIMP,i);
|
||||
NSArray * currentValueArray = [headerDict objectForKey:currentKey];
|
||||
if ([currentValueArray isKindOfClass:[NSArray class]])
|
||||
{
|
||||
int x = 0;
|
||||
int valueCount = [currentValueArray count];
|
||||
for (; x < valueCount; x++)
|
||||
{
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,currentKey);
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,HEADERSEP);
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,[currentValueArray objectAtIndex:x]);
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,NEWLINE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString * myStrValue = (NSString*) currentValueArray;
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,currentKey);
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,HEADERSEP);
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,myStrValue);
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,NEWLINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//PRIVATE
|
||||
void _sendMessage(GSWResponse * message, NSFileHandle* fh, NSString * httpVersion, GSWRequest * request, NSMutableString * headers)
|
||||
void _sendMessage(GSWResponse * message,
|
||||
NSFileHandle* fh,
|
||||
NSString * httpVersion,
|
||||
GSWRequest * request,
|
||||
NSMutableString * headers,
|
||||
IMP* headersAppStringIMPPtr)
|
||||
{
|
||||
int contentLength = 0;
|
||||
//BOOL keepAlive = NO;
|
||||
|
@ -228,27 +240,27 @@ void _sendMessage(GSWResponse * message, NSFileHandle* fh, NSString * httpVersio
|
|||
requestIsHead = [[request method] isEqualToString:HEAD];
|
||||
}
|
||||
|
||||
[headers appendString:GSWIntToNSString([message status])];
|
||||
[headers appendString:URIResponseString];
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,GSWIntToNSString([message status]));
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,URIResponseString);
|
||||
|
||||
_appendMessageHeaders(message,headers);
|
||||
_appendMessageHeaders(message,headers,headersAppStringIMPPtr);
|
||||
|
||||
if ([httpVersion isEqualToString:HTTP11]) {
|
||||
// bug #24006 keep-alive is not implemented.
|
||||
// I am uable to reproduce the need for double clicking on links/forms,
|
||||
// but for now, we send close. -- dw
|
||||
if (YES /*keepAlive == NO*/) {
|
||||
[headers appendString:@"Connection: close\r\n"];
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,@"Connection: close\r\n");
|
||||
} else {
|
||||
[headers appendString:@"Connection: keep-alive\r\n"];
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,@"Connection: keep-alive\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
if ((contentLength > 0) || _alwaysAppendContentLength) {
|
||||
[headers appendString:CONTENT_LENGTHCOLON];
|
||||
[headers appendString:[NSString stringWithFormat:@"%d\r\n", contentLength]];
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,CONTENT_LENGTHCOLON);
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,[NSString stringWithFormat:@"%d\r\n", contentLength]);
|
||||
}
|
||||
[headers appendString:NEWLINE2];
|
||||
GSWeb_appendStringWithImpPtr(headers,headersAppStringIMPPtr,NEWLINE2);
|
||||
|
||||
[fh writeData: [headers dataUsingEncoding:NSISOLatin1StringEncoding
|
||||
allowLossyConversion:YES]];
|
||||
|
@ -433,11 +445,12 @@ void _sendMessage(GSWResponse * message, NSFileHandle* fh, NSString * httpVersio
|
|||
{
|
||||
NSString * httpVersion = [response httpVersion];
|
||||
NSMutableString * bufferStr = [NSMutableString string];
|
||||
|
||||
[bufferStr appendString:httpVersion];
|
||||
[bufferStr appendString:SPACE];
|
||||
IMP bufferAppStringIMP = NULL;
|
||||
|
||||
_sendMessage(response, fh, httpVersion, request, bufferStr);
|
||||
GSWeb_appendStringWithImpPtr(bufferStr,&bufferAppStringIMP,httpVersion);
|
||||
GSWeb_appendStringWithImpPtr(bufferStr,&bufferAppStringIMP,SPACE);
|
||||
|
||||
_sendMessage(response, fh, httpVersion, request, bufferStr,&bufferAppStringIMP);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -32,12 +32,8 @@
|
|||
#ifndef _GSWHiddenField_h__
|
||||
#define _GSWHiddenField_h__
|
||||
|
||||
//OK
|
||||
//====================================================================
|
||||
@interface GSWHiddenField: GSWInput
|
||||
-(id)initWithName:(NSString*)name
|
||||
associations:(NSDictionary*)associations
|
||||
contentElements:(NSArray*)elements;
|
||||
@end
|
||||
|
||||
|
||||
|
|
|
@ -35,23 +35,38 @@ RCS_ID("$Id$")
|
|||
|
||||
//====================================================================
|
||||
@implementation GSWHiddenField
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
contentElements:(NSArray*)elements
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
|
||||
|
||||
[tmpAssociations setObject:[GSWAssociation associationWithValue:@"hidden"]
|
||||
forKey:@"type"];
|
||||
if ((self=[super initWithName:aName
|
||||
associations:tmpAssociations
|
||||
contentElements:nil])) //No Childs!
|
||||
if ((self=[super initWithName:@"input"
|
||||
associations:associations
|
||||
template:nil])) //No Childs!
|
||||
{
|
||||
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 @"hidden";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendCloseTagToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ static Class NSStringClass = Nil;
|
|||
};
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) dealloc
|
||||
{
|
||||
DESTROY(_action);
|
||||
|
@ -77,90 +78,66 @@ static Class NSStringClass = Nil;
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)name
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
self = [super initWithName:@"a" associations:associations template:template];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
if ((self = [super initWithName:@"a"
|
||||
associations:associations
|
||||
template:template]))
|
||||
{
|
||||
DESTROY(_otherQueryAssociations);
|
||||
_otherQueryAssociations = RETAIN([_associations extractObjectsForKeysWithPrefix:@"?" removePrefix: YES]);
|
||||
|
||||
DESTROY(_otherQueryAssociations);
|
||||
_otherQueryAssociations = RETAIN([_associations extractObjectsForKeysWithPrefix:@"?" removePrefix: YES]);
|
||||
if ([_otherQueryAssociations count] == 0)
|
||||
DESTROY(_otherQueryAssociations);
|
||||
|
||||
// _otherQueryAssociations = (((_otherQueryAssociations == nil) ||
|
||||
// ([_otherQueryAssociations count] <= 0)) ? nil : _otherQueryAssociations);
|
||||
GSWAssignAndRemoveAssociation(&_action,_associations,action__Key);
|
||||
GSWAssignAndRemoveAssociation(&_string,_associations,string__Key);
|
||||
GSWAssignAndRemoveAssociation(&_href,_associations,href__Key);
|
||||
GSWAssignAndRemoveAssociation(&_disabled,_associations,disabled__Key);
|
||||
GSWAssignAndRemoveAssociation(&_queryDictionary,_associations,queryDictionary__Key);
|
||||
GSWAssignAndRemoveAssociation(&_actionClass,_associations,actionClass__Key);
|
||||
GSWAssignAndRemoveAssociation(&_directActionName,_associations,directActionName__Key);
|
||||
GSWAssignAndRemoveAssociation(&_pageName,_associations,pageName__Key);
|
||||
GSWAssignAndRemoveAssociation(&_fragmentIdentifier,_associations,fragmentIdentifier__Key);
|
||||
GSWAssignAndRemoveAssociation(&_secure,_associations,secure__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(_string, [_associations objectForKey: string__Key]);
|
||||
if (_string != nil) {
|
||||
[_associations removeObjectForKey: string__Key];
|
||||
}
|
||||
ASSIGN(_disabled, [_associations objectForKey: disabled__Key]);
|
||||
if (_disabled != nil) {
|
||||
[_associations removeObjectForKey: disabled__Key];
|
||||
}
|
||||
ASSIGN(_queryDictionary, [_associations objectForKey: queryDictionary__Key]);
|
||||
if (_queryDictionary != nil) {
|
||||
[_associations removeObjectForKey: queryDictionary__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(_pageName, [_associations objectForKey: pageName__Key]);
|
||||
if (_pageName != nil) {
|
||||
[_associations removeObjectForKey: pageName__Key];
|
||||
}
|
||||
ASSIGN(_secure, [_associations objectForKey: secure__Key]);
|
||||
if (_secure != nil) {
|
||||
[_associations removeObjectForKey: secure__Key];
|
||||
}
|
||||
ASSIGN(_fragmentIdentifier, [_associations objectForKey: fragmentIdentifier__Key]);
|
||||
if (_fragmentIdentifier != nil) {
|
||||
[_associations removeObjectForKey: fragmentIdentifier__Key];
|
||||
}
|
||||
|
||||
if ((_action == nil) && (_href == nil) && (_pageName == nil) &&
|
||||
(_directActionName == nil) && (_actionClass == nil)) {
|
||||
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Missing required attribute: 'action' or 'href' or 'pageName' or 'directActionName' or 'actionClass'",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
if (((_action != nil) && (_href != nil)) || ((_action != nil) && (_pageName != nil)) ||
|
||||
((_href != nil) && (_pageName != nil)) || ((_action != nil) &&
|
||||
(_directActionName != nil)) || ((_href != nil) && (_directActionName != nil)) || ((_pageName != nil) &&
|
||||
(_directActionName != nil)) || ((_action != nil) && (_actionClass != nil))) {
|
||||
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: At least two of these conflicting attributes are present: 'action', 'href', 'pageName', 'directActionName', 'actionClass'.",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
if ((_action != nil) && ([_action isValueConstant])) {
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: 'action' is a constant.",
|
||||
__PRETTY_FUNCTION__];
|
||||
|
||||
}
|
||||
if (_action == nil
|
||||
&& _href == nil
|
||||
&& _pageName == nil
|
||||
&& _directActionName == nil
|
||||
&& _actionClass == nil)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Missing required attribute: 'action' or 'href' or 'pageName' or 'directActionName' or 'actionClass'",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
if ((_action != nil && _href != nil)
|
||||
|| (_action != nil && _pageName != nil)
|
||||
|| (_href != nil && _pageName != nil)
|
||||
|| (_action != nil && _directActionName != nil)
|
||||
|| (_href != nil && _directActionName != nil)
|
||||
|| (_pageName != nil && _directActionName != nil)
|
||||
|| (_action != nil && _actionClass != nil))
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: At least two of these conflicting attributes are present: 'action', 'href', 'pageName', 'directActionName', 'actionClass'.",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
if (_action != nil
|
||||
&& [_action isValueConstant])
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: 'action' is a constant.",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id) description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%s %p action: %@ actionClass: %@ directActionName: %@ href:%@ string:%@ queryDictionary: %@ otherQueryAssociations: %@ pageName: %@ fragmentIdentifier:%@ disabled:%@ secure:%@ >",
|
||||
|
@ -171,78 +148,94 @@ static Class NSStringClass = Nil;
|
|||
_fragmentIdentifier, _disabled, _secure];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// isDisabled in wo5
|
||||
- (BOOL) isDisabledInContext:(GSWContext *) context
|
||||
{
|
||||
return ((_disabled != nil) && ([_disabled boolValueInComponent: GSWContext_component(context)]));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(GSWElement*)invokeActionForRequest:(GSWRequest*) request
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
NSString * str = nil;
|
||||
id obj = nil;
|
||||
id value = nil;
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
GSWElement* result = nil;
|
||||
|
||||
if ([[context elementID] isEqual:[context senderID]]) {
|
||||
if ((_disabled == nil) || (![_disabled boolValueInComponent:component])) {
|
||||
if (_pageName != nil) {
|
||||
value = [_pageName valueInComponent:component];
|
||||
if (value != nil) {
|
||||
str = value; //stringValue;
|
||||
}
|
||||
}
|
||||
if (_action != nil) {
|
||||
obj = [_action valueInComponent:component];
|
||||
} else {
|
||||
if (_pageName == nil) {
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s: Missing page name.", __PRETTY_FUNCTION__];
|
||||
}
|
||||
if (str != nil) {
|
||||
obj = [GSWApp pageWithName:str inContext:context];
|
||||
} else {
|
||||
// CHECKME: log page name? dave@turbocat.de
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s: cannot find page.", __PRETTY_FUNCTION__];
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//TODO GSWNoContentElement
|
||||
obj = nil;
|
||||
if ([[context elementID] isEqual:[context senderID]])
|
||||
{
|
||||
GSWComponent* component = GSWContext_component(context);
|
||||
if (_disabled == nil
|
||||
|| ![_disabled boolValueInComponent:component])
|
||||
{
|
||||
NSString* pageName = nil;
|
||||
if (_pageName != nil)
|
||||
{
|
||||
pageName = NSStringWithObject([_pageName valueInComponent:component]);
|
||||
}
|
||||
if (_action != nil)
|
||||
{
|
||||
result = [_action valueInComponent:component];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_pageName == nil)
|
||||
{
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s: Missing page name.", __PRETTY_FUNCTION__];
|
||||
}
|
||||
if (pageName != nil)
|
||||
{
|
||||
result = [GSWApp pageWithName:pageName
|
||||
inContext:context];
|
||||
}
|
||||
else
|
||||
{
|
||||
// CHECKME: log page name? dave@turbocat.de
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s: cannot find page.", __PRETTY_FUNCTION__];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO GSWNoContentElement
|
||||
result = nil;
|
||||
}
|
||||
if (result == nil)
|
||||
{
|
||||
result = [context page];
|
||||
}
|
||||
}
|
||||
if (obj == nil) {
|
||||
obj = [context page];
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
return result;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendOpenTagToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
if (! [self isDisabledInContext:context]) {
|
||||
[super _appendOpenTagToResponse:response
|
||||
inContext:context];
|
||||
}
|
||||
if (![self isDisabledInContext:context])
|
||||
{
|
||||
[super _appendOpenTagToResponse:response
|
||||
inContext:context];
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendCloseTagToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
if (! [self isDisabledInContext:context]) {
|
||||
[super _appendCloseTagToResponse:response
|
||||
inContext:context];
|
||||
}
|
||||
if (![self isDisabledInContext:context])
|
||||
{
|
||||
[super _appendCloseTagToResponse:response
|
||||
inContext:context];
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendQueryStringToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
NSString * str = nil;
|
||||
|
||||
GSOnceMLog(@"%s is deprecated, use _appendQueryStringToResponse: inContext: requestHandlerPath: htmlEscapeURL:", __PRETTY_FUNCTION__);
|
||||
|
||||
NSDictionary * queryDict = [self computeQueryDictionaryWithActionClassAssociation: _actionClass
|
||||
|
@ -254,18 +247,18 @@ static Class NSStringClass = Nil;
|
|||
if (queryDict != nil
|
||||
&& [queryDict count] > 0)
|
||||
{
|
||||
str = [queryDict encodeAsCGIFormValues];
|
||||
NSString* queryString = [queryDict encodeAsCGIFormValues];
|
||||
GSWResponse_appendContentCharacter(response,'?');
|
||||
GSWResponse_appendContentHTMLAttributeValue(response, str);
|
||||
GSWResponse_appendContentHTMLAttributeValue(response, queryString);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendQueryStringToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
requestHandlerPath: (NSString*) aRequestHandlerPath
|
||||
htmlEscapeURL: (BOOL) htmlEscapeURL
|
||||
{
|
||||
NSString * str = nil;
|
||||
NSString * path = (aRequestHandlerPath == nil ? @"" : aRequestHandlerPath);
|
||||
|
||||
NSDictionary * queryDict = [self computeQueryDictionaryWithRequestHandlerPath: path
|
||||
|
@ -273,28 +266,32 @@ static Class NSStringClass = Nil;
|
|||
otherQueryAssociations: _otherQueryAssociations
|
||||
inContext: context];
|
||||
|
||||
if (queryDict != nil && [queryDict count] > 0)
|
||||
if ([queryDict count] > 0)
|
||||
{
|
||||
str = [queryDict encodeAsCGIFormValuesEscapeAmpersand:htmlEscapeURL];
|
||||
NSString* queryString = [queryDict encodeAsCGIFormValuesEscapeAmpersand:htmlEscapeURL];
|
||||
GSWResponse_appendContentCharacter(response,'?');
|
||||
GSWResponse_appendContentHTMLAttributeValue(response, str);
|
||||
GSWResponse_appendContentHTMLAttributeValue(response, queryString);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendFragmentToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
|
||||
{
|
||||
if (_fragmentIdentifier != nil) {
|
||||
id obj = [_fragmentIdentifier valueInComponent:GSWContext_component(context)];
|
||||
if (obj != nil) {
|
||||
GSWResponse_appendContentCharacter(response,'#');
|
||||
GSWResponse_appendContentString(response, obj); // [obj stringValue] ??
|
||||
if (_fragmentIdentifier != nil)
|
||||
{
|
||||
NSString* fragment = [_fragmentIdentifier valueInComponent:GSWContext_component(context)];
|
||||
if (fragment != nil)
|
||||
{
|
||||
GSWResponse_appendContentCharacter(response,'#');
|
||||
GSWResponse_appendContentString(response, NSStringWithObject(fragment));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)_appendCGIActionURLToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -329,6 +326,7 @@ static Class NSStringClass = Nil;
|
|||
inContext:context];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendAttributesToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -350,24 +348,16 @@ static Class NSStringClass = Nil;
|
|||
else if (_action != nil || _pageName != nil)
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
BOOL securestuff = (_secure != nil ? [_secure boolValueInComponent:component] : NO);
|
||||
BOOL completeURLsOriginalState=NO;
|
||||
BOOL secure = (_secure != nil ? [_secure boolValueInComponent:component] : NO);
|
||||
|
||||
GSWResponse_appendContentCharacter(response,' ');
|
||||
GSWResponse_appendContentAsciiString(response, href__Key);
|
||||
GSWResponse_appendContentCharacter(response,'=');
|
||||
GSWResponse_appendContentCharacter(response,'"');
|
||||
|
||||
if (securestuff)
|
||||
completeURLsOriginalState=[context _generateCompleteURLs];
|
||||
|
||||
GSWResponse_appendContentString(response,
|
||||
[context _componentActionURL]);
|
||||
[context _componentActionURLIsSecure:secure]);
|
||||
|
||||
if (securestuff
|
||||
&& !completeURLsOriginalState)
|
||||
[context _generateRelativeURLs];
|
||||
|
||||
[self _appendQueryStringToResponse:response
|
||||
inContext:context
|
||||
requestHandlerPath:nil
|
||||
|
@ -393,7 +383,8 @@ static Class NSStringClass = Nil;
|
|||
GSWResponse_appendContentCharacter(response,'=');
|
||||
GSWResponse_appendContentCharacter(response,'"');
|
||||
|
||||
if ([hrefValue isRelativeURL] && ![hrefValue isFragmentURL])
|
||||
if ([hrefValue isRelativeURL]
|
||||
&& ![hrefValue isFragmentURL])
|
||||
{
|
||||
NSString * url = [context _urlForResourceNamed:hrefValue
|
||||
inFramework:nil];
|
||||
|
@ -444,17 +435,19 @@ static Class NSStringClass = Nil;
|
|||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendContentStringToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
if (_string != nil)
|
||||
{
|
||||
id stringValue = [_string valueInComponent:GSWContext_component(context)];
|
||||
if (stringValue != nil)
|
||||
GSWResponse_appendContentString(response,NSStringWithObject(stringValue));
|
||||
NSString* string = [_string valueInComponent:GSWContext_component(context)];
|
||||
if (string != nil)
|
||||
GSWResponse_appendContentString(response,NSStringWithObject(string));
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendChildrenToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
|
220
GSWeb/GSWImage.m
220
GSWeb/GSWImage.m
|
@ -42,25 +42,17 @@ RCS_ID("$Id$")
|
|||
associations:(NSDictionary*) associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
self = [super initWithName: @"img"
|
||||
associations: associations
|
||||
template: template];
|
||||
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
|
||||
BOOL hasFilename=([associations objectForKey: filename__Key] != nil);
|
||||
if ((self = [super initWithName: @"img"
|
||||
associations: associations
|
||||
template: template]))
|
||||
{
|
||||
if (hasFilename)
|
||||
{
|
||||
GSWAssignAndRemoveAssociation(&_width,_associations,width__Key);
|
||||
GSWAssignAndRemoveAssociation(&_height,_associations,height__Key);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
};
|
||||
|
||||
|
@ -84,7 +76,6 @@ RCS_ID("$Id$")
|
|||
return @"src";
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)description
|
||||
{
|
||||
|
@ -94,6 +85,7 @@ RCS_ID("$Id$")
|
|||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
/* This class method does not actually exist in WO45 yet it seems subsequent
|
||||
* versions implement it to factor out code replicated by mutliple classes
|
||||
* across the class hierarchy.
|
||||
|
@ -105,107 +97,91 @@ RCS_ID("$Id$")
|
|||
width:(GSWAssociation*) width
|
||||
height:(GSWAssociation*) height
|
||||
{
|
||||
GSWResourceManager *resourcemanager;
|
||||
GSWComponent *component;
|
||||
NSString *fileNameValue;
|
||||
NSString *frameworkName = nil;
|
||||
NSString *resourceURL;
|
||||
|
||||
resourcemanager = [GSWApp resourceManager];
|
||||
component = GSWContext_component(context);
|
||||
fileNameValue = [filename valueInComponent:component];
|
||||
frameworkName = [GSWHTMLDynamicElement _frameworkNameForAssociation:framework
|
||||
inComponent:component];
|
||||
|
||||
resourceURL = [context _urlForResourceNamed: fileNameValue
|
||||
inFramework: frameworkName];
|
||||
GSWResourceManager *resourcemanager = [GSWApp resourceManager];
|
||||
GSWComponent *component = GSWContext_component(context);
|
||||
NSString *fileNameValue = [filename valueInComponent:component];
|
||||
NSString *frameworkName = [GSWHTMLDynamicElement _frameworkNameForAssociation:framework
|
||||
inComponent:component];
|
||||
NSString *resourceURL = [context _urlForResourceNamed: fileNameValue
|
||||
inFramework: frameworkName];
|
||||
|
||||
if (resourceURL != nil)
|
||||
{
|
||||
NSString *widthStr = nil;
|
||||
NSString *heightStr = nil;
|
||||
BOOL calculateWidth = NO;
|
||||
BOOL calculateHeight = NO;
|
||||
|
||||
if (width != nil)
|
||||
{
|
||||
id widthValue;
|
||||
widthValue = [width valueInComponent:component];
|
||||
if (widthValue)
|
||||
{
|
||||
widthStr = NSStringWithObject(widthValue);
|
||||
}
|
||||
calculateWidth = (widthStr == nil || [widthStr isEqual:@"*"]);
|
||||
}
|
||||
if (height != nil)
|
||||
{
|
||||
id heightValue;
|
||||
heightValue = [height valueInComponent:component];
|
||||
if (heightValue)
|
||||
{
|
||||
heightStr = NSStringWithObject(heightValue);
|
||||
}
|
||||
calculateHeight = (heightStr == nil || [heightStr isEqual:@"*"]);
|
||||
}
|
||||
|
||||
if (calculateWidth || calculateHeight)
|
||||
{
|
||||
GSWImageInfo * imageinfo;
|
||||
NSString *widthStr = nil;
|
||||
NSString *heightStr = nil;
|
||||
BOOL calculateWidth = NO;
|
||||
BOOL calculateHeight = NO;
|
||||
|
||||
GSOnceMLog(@"%@: No height or width information provided for '%@'. If possible, this information should be provided for best performance.",
|
||||
NSStringFromClass([self class]), fileNameValue);
|
||||
if (width != nil)
|
||||
{
|
||||
widthStr = NSStringWithObject([width valueInComponent:component]);
|
||||
calculateWidth = (widthStr == nil || [widthStr isEqual:@"*"]);
|
||||
}
|
||||
if (height != nil)
|
||||
{
|
||||
heightStr = NSStringWithObject([height valueInComponent:component]);
|
||||
calculateHeight = (heightStr == nil || [heightStr isEqual:@"*"]);
|
||||
}
|
||||
|
||||
imageinfo = [resourcemanager _imageInfoForUrl: resourceURL
|
||||
fileName: fileNameValue
|
||||
framework: frameworkName
|
||||
languages: [context languages]];
|
||||
if (imageinfo != nil)
|
||||
if (calculateWidth || calculateHeight)
|
||||
{
|
||||
GSWImageInfo * imageinfo;
|
||||
|
||||
GSOnceMLog(@"%@: No height or width information provided for '%@'. If possible, this information should be provided for best performance.",
|
||||
NSStringFromClass([self class]), fileNameValue);
|
||||
|
||||
imageinfo = [resourcemanager _imageInfoForUrl: resourceURL
|
||||
fileName: fileNameValue
|
||||
framework: frameworkName
|
||||
languages: [context languages]];
|
||||
if (imageinfo != nil)
|
||||
{
|
||||
if (calculateWidth)
|
||||
{
|
||||
widthStr = [imageinfo widthString];
|
||||
}
|
||||
widthStr = [imageinfo widthString];
|
||||
if (calculateHeight)
|
||||
{
|
||||
heightStr = [imageinfo heightString];
|
||||
}
|
||||
heightStr = [imageinfo heightString];
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
NSLog(@"%@: Could not get height/width information for image at '%@' '%@' '%@'",
|
||||
NSStringFromClass([self class]), resourceURL,
|
||||
fileNameValue, frameworkName);
|
||||
fileNameValue, frameworkName);
|
||||
}
|
||||
}
|
||||
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
@"src",
|
||||
resourceURL,
|
||||
NO);
|
||||
|
||||
if (widthStr != nil)
|
||||
{
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
@"width",
|
||||
widthStr,
|
||||
NO);
|
||||
}
|
||||
if (heightStr != nil)
|
||||
{
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
@"height",
|
||||
heightStr,
|
||||
NO);
|
||||
}
|
||||
}
|
||||
|
||||
[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
|
||||
{
|
||||
NSString *message
|
||||
= [resourcemanager errorMessageUrlForResourceNamed: fileNameValue
|
||||
inFramework: frameworkName];
|
||||
[response _appendTagAttribute:@"src"
|
||||
value: message
|
||||
escapingHTMLAttributeValue:NO];
|
||||
{
|
||||
NSString *message
|
||||
= [resourcemanager errorMessageUrlForResourceNamed: fileNameValue
|
||||
inFramework: frameworkName];
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
@"src",
|
||||
message,
|
||||
NO);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// used from GSWActiveImage
|
||||
// _appendImageSizetoResponseInContext
|
||||
|
||||
|
@ -215,28 +191,26 @@ RCS_ID("$Id$")
|
|||
height:(GSWAssociation *) height
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
NSString * widthValue = nil;
|
||||
NSString * heightValue = nil;
|
||||
|
||||
if (width) {
|
||||
widthValue = [[width valueInComponent:component] description];
|
||||
}
|
||||
if (height) {
|
||||
heightValue = [[height valueInComponent:component] description];
|
||||
}
|
||||
NSString * widthValue = NSStringWithObject([width valueInComponent:component]);
|
||||
NSString * heightValue = NSStringWithObject([height valueInComponent:component]);
|
||||
|
||||
if (widthValue != nil) {
|
||||
[response _appendTagAttribute: @"width"
|
||||
value: widthValue
|
||||
escapingHTMLAttributeValue: NO];
|
||||
}
|
||||
if (heightValue != nil) {
|
||||
[response _appendTagAttribute: @"height"
|
||||
value: heightValue
|
||||
escapingHTMLAttributeValue: NO];
|
||||
}
|
||||
if (widthValue != nil)
|
||||
{
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
@"width",
|
||||
widthValue,
|
||||
NO);
|
||||
}
|
||||
if (heightValue != nil)
|
||||
{
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
@"height",
|
||||
heightValue,
|
||||
NO);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
/* This function exists in WO45 and its implementation coresponds
|
||||
* to the class method. Yet insubesquent versions of WO it has
|
||||
* been consolidated into the class method. We keep this method
|
||||
|
@ -254,12 +228,14 @@ RCS_ID("$Id$")
|
|||
height: _height];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendCloseTagToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
// do nothing!
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
/* This function exists in WO45 and its implementation coresponds
|
||||
* to the class method of GSWHTMLDynamicElement. Yet insubesquent
|
||||
* versions of WO it has been consolidated into the class method.
|
||||
|
|
|
@ -42,180 +42,155 @@ RCS_ID("$Id$")
|
|||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
int imageMapDefNb=0;
|
||||
if ((self = [super initWithName:@"input"
|
||||
associations:associations
|
||||
template: nil]))
|
||||
{
|
||||
int imageMapDefNb=0;
|
||||
if ([_associations objectForKey: type__Key])
|
||||
{
|
||||
[_associations removeObjectForKey: type__Key];
|
||||
NSLog(@"ImageButton: 'type' attribute ignored");
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
GSWAssignAndRemoveAssociation(&_action,_associations,action__Key);
|
||||
if (GSWAssignAndRemoveAssociation(&_imageMapFileName,_associations,imageMapFileName__Key))
|
||||
imageMapDefNb++;
|
||||
GSWAssignAndRemoveAssociation(&_actionClass,_associations,actionClass__Key);
|
||||
GSWAssignAndRemoveAssociation(&_directActionName,_associations,directActionName__Key);
|
||||
GSWAssignAndRemoveAssociation(&_xAssoc,_associations,x__Key);
|
||||
GSWAssignAndRemoveAssociation(&_yAssoc,_associations,y__Key);
|
||||
if (GSWAssignAndRemoveAssociation(&_filename,_associations,filename__Key))
|
||||
{
|
||||
GSWAssignAndRemoveAssociation(&_width,_associations,width__Key);
|
||||
GSWAssignAndRemoveAssociation(&_height,_associations,height__Key);
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
GSWAssignAndRemoveAssociation(&_framework,_associations,framework__Key);
|
||||
GSWAssignAndRemoveAssociation(&_src,_associations,src__Key);
|
||||
GSWAssignAndRemoveAssociation(&_data,_associations,data__Key);
|
||||
GSWAssignAndRemoveAssociation(&_mimeType,_associations,mimeType__Key);
|
||||
GSWAssignAndRemoveAssociation(&_key,_associations,key__Key);
|
||||
|
||||
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 (!WOStrictFlag)
|
||||
{
|
||||
if (GSWAssignAndRemoveAssociation(&_imageMapString,_associations,imageMapString__Key))
|
||||
imageMapDefNb++;
|
||||
|
||||
if (GSWAssignAndRemoveAssociation(&_imageMapRegions,_associations,imageMapRegions__Key))
|
||||
imageMapDefNb++;
|
||||
|
||||
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)
|
||||
|
||||
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__];
|
||||
}
|
||||
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);
|
||||
}
|
||||
GSWAssignAndRemoveAssociation(&_cidStore,_associations,cidStore__Key);
|
||||
GSWAssignAndRemoveAssociation(&_cidKey,_associations,cidKey__Key);
|
||||
} // (!WOStrictFlag)
|
||||
|
||||
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
|
||||
{
|
||||
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;
|
||||
};
|
||||
|
@ -245,6 +220,7 @@ RCS_ID("$Id$")
|
|||
[super dealloc];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%s %p>",
|
||||
|
@ -252,6 +228,7 @@ RCS_ID("$Id$")
|
|||
(void*)self];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(GSWAssociation*)hitTestX:(int)x
|
||||
y:(int)y
|
||||
inRegions:(NSArray*)regions
|
||||
|
@ -267,8 +244,6 @@ RCS_ID("$Id$")
|
|||
return assoc;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)_imageURLInContext:(GSWContext*)aContext
|
||||
{
|
||||
|
@ -277,7 +252,6 @@ RCS_ID("$Id$")
|
|||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
-(void)_appendDirectActionToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -289,7 +263,6 @@ RCS_ID("$Id$")
|
|||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
-(void)appendAttributesToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -305,76 +278,92 @@ RCS_ID("$Id$")
|
|||
[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 (![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) {
|
||||
if (_value != nil)
|
||||
{
|
||||
BOOL secure = (_secure != nil ? [_secure boolValueInComponent:component] : NO);
|
||||
GSWContext_appendZeroElementIDComponent(context);
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
src__Key,
|
||||
[context _componentActionURLIsSecure:secure],
|
||||
NO);
|
||||
GSWContext_deleteLastElementIDComponent(context);
|
||||
}
|
||||
else if (_data != nil
|
||||
&& _mimeType != nil)
|
||||
{
|
||||
[GSWURLValuedElementData _appendDataURLAttributeToResponse: 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];
|
||||
|
||||
[GSWImage _appendFilenameToResponse: response
|
||||
inContext: context
|
||||
framework: _framework
|
||||
filename: _filename
|
||||
width: _width
|
||||
height: _height];
|
||||
|
||||
} else {
|
||||
NSString * srcValue = [_src valueInComponent:component];
|
||||
if (srcValue == nil) {
|
||||
}
|
||||
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.",
|
||||
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];
|
||||
}
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
@"src",
|
||||
srcValue,
|
||||
NO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)appendToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
|
||||
if ([self disabledInComponent: component]) {
|
||||
if ([self disabledInComponent: component])
|
||||
GSWResponse_appendContentAsciiString(response,@"<img");
|
||||
} else {
|
||||
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
|
||||
if (_directActionName != nil
|
||||
|| _actionClass != nil)
|
||||
{
|
||||
GSWResponse_appendContentAsciiString(response,
|
||||
@"<input type=\"hidden\" name=\"GSWSubmitAction\" value=\"");
|
||||
[self _appendDirectActionToResponse:response
|
||||
inContext:context];
|
||||
GSWResponse_appendContentCharacter(response,'>');
|
||||
}
|
||||
GSWResponse_appendContentCharacter(response,'>');
|
||||
}
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -384,162 +373,169 @@ RCS_ID("$Id$")
|
|||
//Does nothing!
|
||||
};
|
||||
|
||||
|
||||
|
||||
// todo: check if 100% compatible
|
||||
//--------------------------------------------------------------------
|
||||
// todo: check if 100% compatible
|
||||
-(id <GSWActionResults>)invokeActionForRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
id <GSWActionResults, NSObject> element=nil;
|
||||
NSObject <GSWActionResults>* element=nil;
|
||||
GSWComponent* component=GSWContext_component(aContext);
|
||||
|
||||
NSString* senderID=nil;
|
||||
NSString* elementID=nil;
|
||||
BOOL isInForm=NO;
|
||||
BOOL XYValues=NO;
|
||||
BOOL thisOne=NO;
|
||||
GSWComponent* component=nil;
|
||||
NSInteger x=0;
|
||||
NSInteger y=0;
|
||||
component=GSWContext_component(aContext);
|
||||
|
||||
GSWContext_appendZeroElementIDComponent(aContext);
|
||||
senderID=GSWContext_senderID(aContext);
|
||||
elementID=GSWContext_elementID(aContext);
|
||||
|
||||
if ([elementID isEqualToString:senderID])
|
||||
{
|
||||
//TODO
|
||||
};
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
if (! [self disabledInComponent: component])
|
||||
{
|
||||
isInForm=[aContext isInForm];
|
||||
if (isInForm)
|
||||
{
|
||||
BOOL wasFormSubmitted=[aContext _wasFormSubmitted];
|
||||
if (wasFormSubmitted)
|
||||
{
|
||||
NSString* nameInContext=[self nameInContext:aContext];
|
||||
NSString* formValueX=[request formValueForKey:[nameInContext stringByAppendingString:@".x"]];
|
||||
NSString* formValueY=[request formValueForKey:[nameInContext stringByAppendingString:@".y"]];
|
||||
|
||||
if (formValueX && formValueY)
|
||||
{
|
||||
x=[formValueX intValue];
|
||||
y=[formValueY intValue];
|
||||
XYValues=YES;
|
||||
thisOne=YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO
|
||||
//thisOne=YES;//??
|
||||
};
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
elementID=GSWContext_elementID(aContext);
|
||||
|
||||
if ([elementID isEqualToString:senderID])
|
||||
{
|
||||
id param=[request formValueForKey:GSWKey_IsmapCoords[GSWebNamingConv]];
|
||||
|
||||
if (param)
|
||||
{
|
||||
if ([param ismapCoordx:&x
|
||||
y:&y])
|
||||
XYValues=YES;
|
||||
else
|
||||
{
|
||||
//TODO
|
||||
};
|
||||
};
|
||||
thisOne=YES;
|
||||
};
|
||||
};
|
||||
if (thisOne)
|
||||
{
|
||||
GSWAssociation* actionAssociation=nil;
|
||||
NSArray* regions=nil;
|
||||
if (_imageMapFileName)
|
||||
{
|
||||
id imageMapFileNameValue=[_imageMapFileName valueInComponent:component];
|
||||
NSString* imageMapFilePath;
|
||||
|
||||
imageMapFilePath=[[GSWApp resourceManager] pathForResourceNamed:imageMapFileNameValue
|
||||
inFramework:nil
|
||||
languages:[aContext 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 && [element isKindOfClass:[GSWComponent class]])
|
||||
{
|
||||
// call awakeInContext when _element is sleeping deeply
|
||||
[(GSWComponent*)element ensureAwakeInContext:aContext];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if (href)
|
||||
{
|
||||
[aContext _setActionInvoked:YES];
|
||||
//TODO redirect to href
|
||||
}
|
||||
else*/
|
||||
if (_action)
|
||||
{
|
||||
[aContext _setActionInvoked:YES];
|
||||
element=[_action valueInComponent:component];
|
||||
|
||||
if (element && [element isKindOfClass:[GSWComponent class]])
|
||||
{
|
||||
// call awakeInContext when _element is sleeping deeply
|
||||
[(GSWComponent*)element ensureAwakeInContext:aContext];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// NSDebugMLLog0(@"gswdync",@"GSWActiveImage Couldn't trigger action.");
|
||||
};
|
||||
};
|
||||
if (!element)
|
||||
element=[aContext page];
|
||||
}
|
||||
else
|
||||
element = (id <GSWActionResults, NSObject>) [super invokeActionForRequest:request
|
||||
inContext:aContext];
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
if (_value != nil)
|
||||
element=[_value valueInComponent:component];
|
||||
}
|
||||
else
|
||||
element = (id <GSWActionResults, NSObject>) [super invokeActionForRequest:request
|
||||
inContext:aContext];
|
||||
{
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
elementID=GSWContext_elementID(aContext);
|
||||
|
||||
if (![self disabledInComponent: component])
|
||||
{
|
||||
isInForm=[aContext isInForm];
|
||||
if (isInForm)
|
||||
{
|
||||
BOOL wasFormSubmitted=[aContext _wasFormSubmitted];
|
||||
if (wasFormSubmitted)
|
||||
{
|
||||
NSString* nameInContext=[self nameInContext:aContext];
|
||||
NSString* formValueX=[request formValueForKey:[nameInContext stringByAppendingString:@".x"]];
|
||||
NSString* formValueY=[request formValueForKey:[nameInContext stringByAppendingString:@".y"]];
|
||||
|
||||
if (formValueX && formValueY)
|
||||
{
|
||||
x=[formValueX intValue];
|
||||
y=[formValueY intValue];
|
||||
XYValues=YES;
|
||||
thisOne=YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO
|
||||
//thisOne=YES;//??
|
||||
};
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
elementID=GSWContext_elementID(aContext);
|
||||
|
||||
if ([elementID isEqualToString:senderID])
|
||||
{
|
||||
id param=[request formValueForKey:GSWKey_IsmapCoords[GSWebNamingConv]];
|
||||
|
||||
if (param)
|
||||
{
|
||||
if ([param ismapCoordx:&x
|
||||
y:&y])
|
||||
XYValues=YES;
|
||||
else
|
||||
{
|
||||
//TODO
|
||||
};
|
||||
};
|
||||
thisOne=YES;
|
||||
};
|
||||
};
|
||||
if (thisOne)
|
||||
{
|
||||
GSWAssociation* actionAssociation=nil;
|
||||
NSArray* regions=nil;
|
||||
if (_imageMapFileName)
|
||||
{
|
||||
id imageMapFileNameValue=[_imageMapFileName valueInComponent:component];
|
||||
NSString* imageMapFilePath;
|
||||
|
||||
imageMapFilePath=[[GSWApp resourceManager] pathForResourceNamed:imageMapFileNameValue
|
||||
inFramework:nil
|
||||
languages:[aContext 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
|
||||
&& [element isKindOfClass:[GSWComponent class]])
|
||||
{
|
||||
// call awakeInContext when _element is sleeping deeply
|
||||
[(GSWComponent*)element ensureAwakeInContext:aContext];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if (href)
|
||||
{
|
||||
[aContext _setActionInvoked:YES];
|
||||
//TODO redirect to href
|
||||
}
|
||||
else*/
|
||||
if (_action)
|
||||
{
|
||||
[aContext _setActionInvoked:YES];
|
||||
element=[_action valueInComponent:component];
|
||||
|
||||
if (element && [element isKindOfClass:[GSWComponent class]])
|
||||
{
|
||||
// call awakeInContext when _element is sleeping deeply
|
||||
[(GSWComponent*)element ensureAwakeInContext:aContext];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//NSDebugMLLog0(@"gswdync",@"GSWActiveImage Couldn't trigger action.");
|
||||
};
|
||||
};
|
||||
if (!element)
|
||||
element=[aContext page];
|
||||
}
|
||||
else
|
||||
element = (id <GSWActionResults, NSObject>) [super invokeActionForRequest:request
|
||||
inContext:aContext];
|
||||
}
|
||||
else
|
||||
element = (id <GSWActionResults, NSObject>) [super invokeActionForRequest:request
|
||||
inContext:aContext];
|
||||
}
|
||||
return element;
|
||||
};
|
||||
|
||||
|
|
|
@ -45,10 +45,6 @@
|
|||
GSWAssociation * _escapeHTML;
|
||||
}
|
||||
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
contentElements:(NSMutableArray*) elements;
|
||||
|
||||
- (BOOL) disabledInComponent:(GSWComponent*) component;
|
||||
|
||||
|
||||
|
|
323
GSWeb/GSWInput.m
323
GSWeb/GSWInput.m
|
@ -51,190 +51,24 @@ static Class standardClass = Nil;
|
|||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
contentElements:(NSMutableArray*) elements
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
self = [super initWithName:aName associations:associations template: template];
|
||||
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];
|
||||
}
|
||||
if (([super initWithName:aName
|
||||
associations:associations
|
||||
template: template]))
|
||||
{
|
||||
GSWAssignAndRemoveAssociation(&_disabled,_associations,disabled__Key);
|
||||
GSWAssignAndRemoveAssociation(&_name,_associations,name__Key);
|
||||
GSWAssignAndRemoveAssociation(&_value,_associations,value__Key);
|
||||
GSWAssignAndRemoveAssociation(&_escapeHTML,_associations,escapeHTML__Key);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
-(NSString*) type
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (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];
|
||||
}
|
||||
|
||||
- (BOOL) disabledInComponent:(GSWComponent*) component
|
||||
{
|
||||
return ((_disabled != nil) && ([_disabled boolValueInComponent: component]));
|
||||
}
|
||||
|
||||
-(NSString*)nameInContext:(GSWContext*)context
|
||||
{
|
||||
NSString * s = nil;
|
||||
|
||||
if (_name != nil) {
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
|
||||
id obj = [_name valueInComponent:component];
|
||||
if (obj != nil) {
|
||||
return obj; // stringValue?
|
||||
}
|
||||
}
|
||||
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__];
|
||||
}
|
||||
// make the compiler happy ;)
|
||||
return nil;
|
||||
}
|
||||
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (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];
|
||||
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);
|
||||
|
@ -245,4 +79,141 @@ static Class standardClass = Nil;
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*) type
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSString*) constantAttributesRepresentation
|
||||
{
|
||||
if (_constantAttributesRepresentation == nil)
|
||||
{
|
||||
NSString * s = [self type];
|
||||
if (s != nil)
|
||||
{
|
||||
IMP asIMP=NULL;
|
||||
[super constantAttributesRepresentation];
|
||||
NSMutableString * buffer = [NSMutableString stringWithCapacity:256];
|
||||
if (_constantAttributesRepresentation != nil)
|
||||
GSWeb_appendStringWithImpPtr(buffer,&asIMP,_constantAttributesRepresentation);
|
||||
|
||||
GSWeb_appendStringWithImpPtr(buffer,&asIMP,@" type=\"");
|
||||
GSWeb_appendStringWithImpPtr(buffer,&asIMP,s);
|
||||
GSWeb_appendStringWithImpPtr(buffer,&asIMP,@"\"");
|
||||
|
||||
ASSIGN(_constantAttributesRepresentation,buffer);
|
||||
}
|
||||
}
|
||||
return [super constantAttributesRepresentation];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (BOOL) disabledInComponent:(GSWComponent*) component
|
||||
{
|
||||
return (_disabled != nil
|
||||
&& [_disabled boolValueInComponent: component]);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)nameInContext:(GSWContext*)context
|
||||
{
|
||||
NSString * s = nil;
|
||||
|
||||
if (_name != nil)
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
s = NSStringWithObject([_name valueInComponent:component]);
|
||||
}
|
||||
if (s==nil)
|
||||
{
|
||||
s = [context elementID];
|
||||
if (s == nil)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Cannot evaluate 'name' attribute, and context element ID is nil.",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
|
||||
if (![self disabledInComponent: component]
|
||||
&& [context _wasFormSubmitted])
|
||||
{
|
||||
NSString* name = [self nameInContext:context];
|
||||
if (name != nil)
|
||||
{
|
||||
NSString* value = [request stringFormValueForKey:name];
|
||||
[_value setValue: value
|
||||
inComponent:component];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (BOOL) _shouldEscapeHTML:(GSWComponent *) component
|
||||
{
|
||||
BOOL flag = YES;
|
||||
if (_escapeHTML != nil)
|
||||
flag = [_escapeHTML boolValueInComponent:component];
|
||||
return flag;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (void) _appendNameAttributeToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
NSString* name = [self nameInContext:context];
|
||||
if (name != nil)
|
||||
{
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
name__Key,
|
||||
name,
|
||||
YES);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (void) _appendValueAttributeToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
if (_value != nil)
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
NSString* value=NSStringWithObject([_value valueInComponent:component]);
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
value__Key,
|
||||
value,
|
||||
[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];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -35,27 +35,19 @@ RCS_ID("$Id$")
|
|||
|
||||
//====================================================================
|
||||
@implementation GSWJavaScript
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)templateElement
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
GSWAssociation* languageAssociation=nil;
|
||||
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
|
||||
|
||||
if (![tmpAssociations objectForKey:language__Key])
|
||||
{
|
||||
// Create and set the language (Javascript)
|
||||
languageAssociation=[GSWConstantValueAssociation associationWithValue:@"JavaScript"];
|
||||
[tmpAssociations setObject:languageAssociation
|
||||
forKey:language__Key];
|
||||
};
|
||||
if ((self=[super initWithName:aName
|
||||
associations:tmpAssociations
|
||||
template:templateElement]))
|
||||
associations:associations
|
||||
template:template]))
|
||||
{
|
||||
[self setLanguage:@"JavaScript"];
|
||||
};
|
||||
return self;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
@end
|
||||
|
|
|
@ -35,6 +35,7 @@ RCS_ID("$Id$")
|
|||
#include <GNUstepBase/Unicode.h>
|
||||
#include "GSWeb.h"
|
||||
#include "NSData+Compress.h"
|
||||
#include "GSWPrivate.h"
|
||||
#include <GNUstepBase/NSObject+GNUstepBase.h>
|
||||
|
||||
|
||||
|
@ -1108,10 +1109,11 @@ NSLog(@"%s - '%s' '%@'",__PRETTY_FUNCTION__, string, nsstring);
|
|||
int count=[cookies count];
|
||||
GSWCookie* cookie=nil;
|
||||
NSString* cookieString=nil;
|
||||
IMP oaiIMP=NULL;
|
||||
strings=[NSMutableArray array];
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
cookie=[cookies objectAtIndex:i];
|
||||
cookie=GSWeb_objectAtIndexWithImpPtr(cookies,&oaiIMP,i);
|
||||
cookieString=[cookie headerValue];
|
||||
NSAssert(cookieString,@"No cookie HeaderValue");
|
||||
[strings addObject:cookieString];
|
||||
|
@ -1225,12 +1227,13 @@ NSLog(@"%s - '%s' '%@'",__PRETTY_FUNCTION__, string, nsstring);
|
|||
{
|
||||
NSMutableData* cachedData=nil;
|
||||
int cacheStackCount=0;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
cacheStackCount=[_cachesStack count];
|
||||
|
||||
if (cacheIndex<cacheStackCount)
|
||||
{
|
||||
cachedData=[_cachesStack objectAtIndex:cacheIndex];
|
||||
cachedData=GSWeb_objectAtIndexWithImpPtr(_cachesStack,&oaiIMP,cacheIndex);
|
||||
AUTORELEASE(RETAIN(cachedData));
|
||||
|
||||
// Last one ? (normal case)
|
||||
|
@ -1244,7 +1247,7 @@ NSLog(@"%s - '%s' '%@'",__PRETTY_FUNCTION__, string, nsstring);
|
|||
cacheIndex++;
|
||||
while(cacheIndex<cacheStackCount)
|
||||
{
|
||||
NSData* tmp=[_cachesStack objectAtIndex:cacheIndex];
|
||||
NSData* tmp=GSWeb_objectAtIndexWithImpPtr(_cachesStack,&oaiIMP,cacheIndex);
|
||||
|
||||
[cachedData appendData:tmp];
|
||||
[_cachesStack removeObjectAtIndex:cacheIndex];
|
||||
|
@ -1255,7 +1258,7 @@ NSLog(@"%s - '%s' '%@'",__PRETTY_FUNCTION__, string, nsstring);
|
|||
//Add cachedData to previous cache item data
|
||||
if (cacheStackCount>0)
|
||||
{
|
||||
_currentCacheData=[_cachesStack objectAtIndex:cacheStackCount-1];
|
||||
_currentCacheData=GSWeb_objectAtIndexWithImpPtr(_cachesStack,&oaiIMP,cacheStackCount-1);
|
||||
_currentCacheDataADImp=NULL;
|
||||
if ([cachedData length]>0)
|
||||
{
|
||||
|
|
|
@ -36,43 +36,52 @@ RCS_ID("$Id$")
|
|||
//====================================================================
|
||||
@implementation GSWPasswordField
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
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__];
|
||||
}
|
||||
if ((self = [super initWithName:@"input"
|
||||
associations:associations
|
||||
template: 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];
|
||||
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
|
||||
{
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
#include <GNUstepBase/NSString+GNUstepBase.h>
|
||||
|
||||
/**
|
||||
|
@ -69,75 +70,44 @@ Bindings
|
|||
//====================================================================
|
||||
@implementation GSWPopUpButton
|
||||
|
||||
static SEL objectAtIndexSEL = NULL;
|
||||
static SEL setValueInComponentSEL = NULL;
|
||||
static SEL valueInComponentSEL = NULL;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GSWPopUpButton class])
|
||||
{
|
||||
objectAtIndexSEL=@selector(objectAtIndex:);
|
||||
setValueInComponentSEL=@selector(setValue:inComponent:);
|
||||
valueInComponentSEL=@selector(valueInComponent:);
|
||||
};
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
self = [super initWithName:@"select" associations:associations template: template];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
if ((self = [super initWithName:@"select"
|
||||
associations:associations
|
||||
template: template]))
|
||||
{
|
||||
_loggedSlow = NO;
|
||||
GSWAssignAndRemoveAssociation(&_list,_associations,list__Key);
|
||||
GSWAssignAndRemoveAssociation(&_item,_associations,item__Key);
|
||||
GSWAssignAndRemoveAssociation(&_string,_associations,displayString__Key);
|
||||
GSWAssignAndRemoveAssociation(&_selection,_associations,selection__Key);
|
||||
GSWAssignAndRemoveAssociation(&_noSelectionString,_associations,noSelectionString__Key);
|
||||
GSWAssignAndRemoveAssociation(&_selectedValue,_associations,selectedValue__Key);
|
||||
|
||||
_loggedSlow = NO;
|
||||
|
||||
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) && ((_item == nil) && ([_item isValueSettable] == NO))) ||
|
||||
(((_string != nil) || (_item != nil)) && (_item == nil)) ||
|
||||
((_selection != nil) && ([_selection isValueSettable] == NO))) {
|
||||
|
||||
[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__];
|
||||
}
|
||||
if (_list == nil
|
||||
|| (_value != nil && (_item == nil && [_item isValueSettable] == NO))
|
||||
|| ((_string != nil || _item != nil) && _item == nil)
|
||||
|| (_selection != nil && [_selection isValueSettable] == NO))
|
||||
{
|
||||
[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
|
||||
{
|
||||
DESTROY(_list);
|
||||
|
@ -150,6 +120,7 @@ static SEL valueInComponentSEL = NULL;
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id) description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%s %p list:%@ item:%@ string:%@ selections:%@ selectedValue:%@ NoSelectionString:%@ >",
|
||||
|
@ -158,6 +129,7 @@ static SEL valueInComponentSEL = NULL;
|
|||
_list, _item, _string, _selection, _selectedValue, _noSelectionString];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (void)_slowTakeValuesFromRequest:(GSWRequest*) request
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -179,13 +151,14 @@ static SEL valueInComponentSEL = NULL;
|
|||
{
|
||||
if ([list isKindOfClass:[NSArray class]])
|
||||
{
|
||||
id item = nil;
|
||||
id value = nil;
|
||||
NSUInteger listCount = [list count];
|
||||
NSUInteger i = 0;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
for(i=0;i<listCount;i++)
|
||||
{
|
||||
item = [list objectAtIndex:i];
|
||||
id value = nil;
|
||||
id item = GSWeb_objectAtIndexWithImpPtr(list,&oaiIMP,i);
|
||||
[_item setValue: item
|
||||
inComponent:component];
|
||||
value = [_value valueInComponent:component];
|
||||
|
@ -217,6 +190,7 @@ static SEL valueInComponentSEL = NULL;
|
|||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (void) _fastTakeValuesFromRequest:(GSWRequest*) request
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -262,6 +236,7 @@ static SEL valueInComponentSEL = NULL;
|
|||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
|
@ -283,11 +258,14 @@ static SEL valueInComponentSEL = NULL;
|
|||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendValueAttributeToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendChildrenToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
@ -340,6 +318,7 @@ static SEL valueInComponentSEL = NULL;
|
|||
NSString* selectedValueString = nil;
|
||||
id selection = nil;
|
||||
int i=0;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
if (_selection != nil)
|
||||
selection = [_selection valueInComponent:component];
|
||||
|
@ -354,7 +333,7 @@ static SEL valueInComponentSEL = NULL;
|
|||
BOOL isSelected = NO;
|
||||
|
||||
if (list != nil)
|
||||
item = [list objectAtIndex:i];
|
||||
item = GSWeb_objectAtIndexWithImpPtr(list,&oaiIMP,i);
|
||||
|
||||
if (_string != nil
|
||||
|| _value != nil)
|
||||
|
@ -388,13 +367,15 @@ static SEL valueInComponentSEL = NULL;
|
|||
|
||||
if (_selection != nil)
|
||||
{
|
||||
isSelected = (selection == nil) ? NO : [selection isEqual:item];
|
||||
if (selection!=nil)
|
||||
isSelected = [selection isEqual:item];
|
||||
}
|
||||
else if (_selectedValue != nil)
|
||||
{
|
||||
if (_value != nil)
|
||||
{
|
||||
isSelected = (selectedValueString == nil) ? NO : [selectedValueString isEqual: valueString];
|
||||
if (selectedValueString)
|
||||
isSelected = [selectedValueString isEqual: valueString];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -432,6 +413,5 @@ static SEL valueInComponentSEL = NULL;
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -55,6 +55,9 @@
|
|||
#include "GSWMessage.h"
|
||||
#include "GSWDefaultAdaptor.h"
|
||||
|
||||
GSWEB_EXPORT SEL gswAppendStringSEL;
|
||||
GSWEB_EXPORT SEL gswObjectAtIndexSEL;
|
||||
|
||||
/** append string to object using appendString: impPtr.
|
||||
If *impPtr is NULL, the method assign it **/
|
||||
static inline void GSWeb_appendStringWithImpPtr(NSMutableString* object,IMP* impPtr,NSString* string)
|
||||
|
@ -62,11 +65,32 @@ static inline void GSWeb_appendStringWithImpPtr(NSMutableString* object,IMP* imp
|
|||
if (object && string)
|
||||
{
|
||||
if (!*impPtr)
|
||||
*impPtr=[object methodForSelector:@selector(appendString:)];
|
||||
(**impPtr)(object,@selector(appendString:),string);
|
||||
{
|
||||
if (gswAppendStringSEL==NULL)
|
||||
GSWInitializeAllMisc();
|
||||
*impPtr=[object methodForSelector:gswAppendStringSEL];
|
||||
}
|
||||
(**impPtr)(object,gswAppendStringSEL,string);
|
||||
};
|
||||
};
|
||||
|
||||
/** get object at index
|
||||
If *impPtr is NULL, the method assign it **/
|
||||
static inline id GSWeb_objectAtIndexWithImpPtr(NSArray* array,IMP* impPtr,NSUInteger index)
|
||||
{
|
||||
if (array)
|
||||
{
|
||||
if (!*impPtr)
|
||||
{
|
||||
if (gswObjectAtIndexSEL==NULL)
|
||||
GSWInitializeAllMisc();
|
||||
*impPtr=[array methodForSelector:gswObjectAtIndexSEL];
|
||||
}
|
||||
return (**impPtr)(array,gswObjectAtIndexSEL,index);
|
||||
}
|
||||
else
|
||||
return nil;
|
||||
};
|
||||
|
||||
@interface GSWComponentDefinition (PrivateDeclarations)
|
||||
|
||||
|
|
|
@ -67,41 +67,36 @@ static Class standardClass = Nil;
|
|||
};
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
self = [super initWithName:@"input" associations:associations template: template];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
if ((self = [super initWithName:@"input"
|
||||
associations:associations
|
||||
template: template]))
|
||||
{
|
||||
GSWAssignAndRemoveAssociation(&_selection,_associations,selection__Key);
|
||||
if (_selection
|
||||
&& ![_selection isValueSettable])
|
||||
{
|
||||
ExceptionRaise0(@"GSWRadioButton",@"'selection' parameter must be settable");
|
||||
}
|
||||
|
||||
ASSIGN(_selection, [_associations objectForKey: selection__Key]);
|
||||
|
||||
if (_selection != nil) {
|
||||
[_associations removeObjectForKey: selection__Key];
|
||||
}
|
||||
GSWAssignAndRemoveAssociation(&_checked,_associations,checked__Key);
|
||||
if (_checked
|
||||
&& ![_checked isValueSettable])
|
||||
{
|
||||
ExceptionRaise0(@"GSWRadioButton",@"'checked' parameter must be settable");
|
||||
};
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
if (!_checked
|
||||
&& (!_value || !_selection))
|
||||
{
|
||||
ExceptionRaise0(@"GSWRadioButton",
|
||||
@"if you don't specify 'checked' parameter, you have to specify 'value' and 'selection' parameter");
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -109,6 +104,7 @@ static Class standardClass = Nil;
|
|||
// [tmpAssociations removeObjectForKey:checked__Key];
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)dealloc
|
||||
{
|
||||
DESTROY(_checked);
|
||||
|
@ -116,6 +112,7 @@ static Class standardClass = Nil;
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id) description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%s %p checked:%@ selection:%@ disabled:%@ name:%@ value:%@>",
|
||||
|
@ -124,79 +121,91 @@ static Class standardClass = Nil;
|
|||
_checked, _selection, _disabled, _name, _value];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSString*) type
|
||||
{
|
||||
return @"radio";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
GSWComponent* component = GSWContext_component(context);
|
||||
BOOL isChecked = NO;
|
||||
id valueValue = nil;
|
||||
|
||||
if ((![self disabledInComponent:component]) && ([context _wasFormSubmitted])) {
|
||||
|
||||
NSString * nameCtx = [self nameInContext:context];
|
||||
|
||||
if (nameCtx != nil) {
|
||||
NSString* value = [request stringFormValueForKey: nameCtx];
|
||||
if (![self disabledInComponent:component]
|
||||
&& [context _wasFormSubmitted])
|
||||
{
|
||||
id value = nil;
|
||||
NSString * nameCtx = [self nameInContext:context];
|
||||
|
||||
if (_value != nil) {
|
||||
valueValue = [_value valueInComponent:component];
|
||||
} else {
|
||||
valueValue = [context elementID];
|
||||
}
|
||||
if (nameCtx != nil)
|
||||
{
|
||||
NSString* formValue = [request stringFormValueForKey: nameCtx];
|
||||
|
||||
isChecked = [value isEqual:NSStringWithObject(valueValue)];
|
||||
if (_value != nil)
|
||||
value = [_value valueInComponent:component];
|
||||
else
|
||||
value = [context elementID];
|
||||
|
||||
isChecked = [formValue isEqual:NSStringWithObject(value)];
|
||||
|
||||
if (isChecked && _selection != nil && _value != nil) {
|
||||
[_selection setValue: valueValue
|
||||
inComponent: component];
|
||||
}
|
||||
|
||||
if (_checked != nil) {
|
||||
[_checked setValue: (isChecked ? GSWNumberYes : GSWNumberNo)
|
||||
inComponent: component];
|
||||
}
|
||||
if (isChecked
|
||||
&& _selection != nil
|
||||
&& _value != nil)
|
||||
{
|
||||
[_selection setValue: value
|
||||
inComponent: component];
|
||||
}
|
||||
|
||||
if (_checked != nil)
|
||||
{
|
||||
[_checked setValue: (isChecked ? GSWNumberYes : GSWNumberNo)
|
||||
inComponent: component];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendCloseTagToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
// nothing!
|
||||
// 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");
|
||||
}
|
||||
if (_value != nil)
|
||||
{
|
||||
id value = [_value valueInComponent:component];
|
||||
if (value != nil
|
||||
&& _selection != nil)
|
||||
{
|
||||
id selection = [_selection valueInComponent:component];
|
||||
if (selection != nil
|
||||
&& [selection isEqual: value])
|
||||
{
|
||||
GSWResponse_appendContentAsciiString(response,@" checked");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // _value == nil
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, value__Key, [context elementID], NO);
|
||||
}
|
||||
if (_checked != nil
|
||||
&& [_checked boolValueInComponent:component])
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
|
||||
/**
|
||||
Bindings
|
||||
|
@ -81,80 +82,44 @@ static Class standardClass = Nil;
|
|||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
GSWAssociation * valueAssoc = nil;
|
||||
if ((self = [super initWithName:aName
|
||||
associations:associations
|
||||
template: template]))
|
||||
{
|
||||
_loggedSlow = NO;
|
||||
|
||||
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__];
|
||||
}
|
||||
|
||||
GSWAssignAndRemoveAssociation(&_suffix,_associations,suffix__Key);
|
||||
GSWAssignAndRemoveAssociation(&_index,_associations,index__Key);
|
||||
GSWAssignAndRemoveAssociation(&_list,_associations,list__Key);
|
||||
GSWAssignAndRemoveAssociation(&_item,_associations,item__Key);
|
||||
GSWAssignAndRemoveAssociation(&_selection,_associations,selection__Key);
|
||||
GSWAssignAndRemoveAssociation(&_prefix,_associations,prefix__Key);
|
||||
GSWAssignAndRemoveAssociation(&_displayString,_associations,displayString__Key);
|
||||
GSWAssignAndRemoveAssociation(&_escapeHTML,_associations,escapeHTML__Key);
|
||||
|
||||
if (_displayString == nil)
|
||||
{
|
||||
ASSIGN(_displayString, _value);
|
||||
_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;
|
||||
}
|
||||
|
||||
|
@ -172,6 +137,7 @@ static Class standardClass = Nil;
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id) description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%s %p list:%@ item:%@ index:%@ selection:%@ prefix:%@ suffix:%@ displayString:%@ escapeHTML:%@>",
|
||||
|
@ -187,53 +153,59 @@ static Class standardClass = Nil;
|
|||
return @"INPUT";
|
||||
};
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)_slowTakeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
|
||||
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;
|
||||
if (![self disabledInComponent:component]
|
||||
&& [context _wasFormSubmitted])
|
||||
{
|
||||
id selection = nil;
|
||||
NSString * ctxName = [self nameInContext:context];
|
||||
NSString * formValue = [request stringFormValueForKey: ctxName];
|
||||
|
||||
if (formValue != nil)
|
||||
{
|
||||
NSArray* list = [_list valueInComponent:component];
|
||||
|
||||
if ([list isKindOfClass:[NSArray class]] == NO)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
|
||||
__PRETTY_FUNCTION__, [list class]];
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
NSUInteger count = [list count];
|
||||
IMP list_oaiIMP=NULL;
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
id value= nil;
|
||||
id item = GSWeb_objectAtIndexWithImpPtr(list,&list_oaiIMP,i);
|
||||
|
||||
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]];
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
[_item setValue:item
|
||||
inComponent:component];
|
||||
|
||||
value = [_value valueInComponent:component];
|
||||
if (value == nil)
|
||||
{
|
||||
NSLog(@"%s: 'value' evaluated to nil in component %@ Unable to select item %@",
|
||||
__PRETTY_FUNCTION__,self,item);
|
||||
}
|
||||
else if ([formValue isEqual:NSStringWithObject(value)])
|
||||
{
|
||||
selection = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
[_selection setValue:selection
|
||||
inComponent:component];
|
||||
}
|
||||
[_selection setValue:selValue
|
||||
inComponent:component];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
@ -242,161 +214,177 @@ static Class standardClass = Nil;
|
|||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
|
||||
if ((_selection != nil) && ((![self disabledInComponent:component]) && ([context _wasFormSubmitted]))) {
|
||||
|
||||
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]];
|
||||
if (_selection != nil
|
||||
&& ![self disabledInComponent:component]
|
||||
&& [context _wasFormSubmitted])
|
||||
{
|
||||
id selection = nil;
|
||||
NSString * ctxName = [self nameInContext:context];
|
||||
NSString * formValue = [request stringFormValueForKey: ctxName];
|
||||
|
||||
if (formValue != nil)
|
||||
{
|
||||
NSArray* list = [_list valueInComponent:component];
|
||||
|
||||
if ([list isKindOfClass:[NSArray class]] == NO)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
|
||||
__PRETTY_FUNCTION__, [list class]];
|
||||
}
|
||||
|
||||
selection = [list objectAtIndex:[formValue intValue]];
|
||||
}
|
||||
[_selection setValue:selection
|
||||
inComponent:component];
|
||||
}
|
||||
[_selection setValue:selValue
|
||||
inComponent:component];
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
-(void)appendToResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
id selectionsValue = nil;
|
||||
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;
|
||||
NSArray* list = [_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]];
|
||||
}
|
||||
|
||||
doEscape = (_escapeHTML == nil) ? _defaultEscapeHTML : [_escapeHTML boolValueInComponent:component];
|
||||
|
||||
|
||||
selectionsValue = _selection == nil ? nil : [_selection valueInComponent:component];
|
||||
|
||||
if (listValue != nil) {
|
||||
count = [listValue count];
|
||||
}
|
||||
|
||||
for (j = 0; j < count; j++)
|
||||
{
|
||||
if (_index != nil) {
|
||||
[_index setValue:GSWIntToNSString(j)
|
||||
inComponent:component];
|
||||
}
|
||||
NSString * prefixStr = nil;
|
||||
NSString * suffixStr = nil;
|
||||
id displayValue = nil;
|
||||
NSString * dispStr = nil;
|
||||
|
||||
valueValue = nil;
|
||||
|
||||
if (_prefix != nil) {
|
||||
prefixStr = NSStringWithObject([_prefix valueInComponent:component]);
|
||||
}
|
||||
|
||||
if (_suffix != nil) {
|
||||
suffixStr = NSStringWithObject([_suffix valueInComponent:component]);
|
||||
}
|
||||
|
||||
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)
|
||||
if (list!=nil)
|
||||
{
|
||||
GSWResponse_appendContentString(response,suffixStr);
|
||||
}
|
||||
}
|
||||
if ([list isKindOfClass:[NSArray class]] == NO)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Evaluating 'list' binding returned a '%@' class and not a NSArray.",
|
||||
__PRETTY_FUNCTION__, [list class]];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSUInteger count=[list count];
|
||||
if (count>0)
|
||||
{
|
||||
int i = 0;
|
||||
BOOL doEscape = (_escapeHTML == nil) ? _defaultEscapeHTML : [_escapeHTML boolValueInComponent:component];
|
||||
NSString* ctxName = [self nameInContext:context];
|
||||
id selection = [_selection valueInComponent:component];
|
||||
IMP list_oaiIMP=NULL;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSString * prefixStr = nil;
|
||||
NSString * suffixStr = nil;
|
||||
NSString * dispStr = nil;
|
||||
id displayValue = nil;
|
||||
id value = nil;
|
||||
id item = nil;
|
||||
|
||||
if (_index != nil)
|
||||
{
|
||||
[_index setValue:GSWIntToNSString(i)
|
||||
inComponent:component];
|
||||
}
|
||||
|
||||
if (_prefix != nil)
|
||||
prefixStr = NSStringWithObject([_prefix valueInComponent:component]);
|
||||
|
||||
if (_suffix != nil)
|
||||
suffixStr = NSStringWithObject([_suffix valueInComponent:component]);
|
||||
|
||||
item = GSWeb_objectAtIndexWithImpPtr(list,&list_oaiIMP,i);
|
||||
|
||||
if (_item != nil
|
||||
&& _displayString != nil)
|
||||
{
|
||||
[_item setValue:item
|
||||
inComponent:component];
|
||||
displayValue = [_displayString valueInComponent:component];
|
||||
|
||||
if (displayValue == nil)
|
||||
{
|
||||
dispStr = NSStringWithObject(item);
|
||||
NSLog(@"%s: 'displayString' evaluated to nil in component %@. Using %@",
|
||||
__PRETTY_FUNCTION__, component, dispStr);
|
||||
}
|
||||
else
|
||||
dispStr = NSStringWithObject(displayValue);
|
||||
}
|
||||
else
|
||||
dispStr = NSStringWithObject(item);
|
||||
|
||||
GSWResponse_appendContentAsciiString(response, @"<input name=\"");
|
||||
GSWResponse_appendContentString(response,ctxName);
|
||||
GSWResponse_appendContentAsciiString(response, @"\" type=radio value=\"");
|
||||
|
||||
if (_value != nil)
|
||||
{
|
||||
value = [_value valueInComponent:component];
|
||||
if (value != nil)
|
||||
GSWResponse_appendContentHTMLConvertString(response,NSStringWithObject(value));
|
||||
else
|
||||
{
|
||||
NSLog(@"%s: 'value' evaluated to nil in component %@. Using index",
|
||||
__PRETTY_FUNCTION__, component);
|
||||
}
|
||||
}
|
||||
|
||||
if (value == nil)
|
||||
GSWResponse_appendContentAsciiString(response,GSWIntToNSString(i));
|
||||
|
||||
if (selection != nil
|
||||
&& [selection isEqual:item])
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
-(BOOL)appendStringAtRight:(id)unkwnon
|
||||
withMapping:(char*)mapping
|
||||
{
|
||||
return NO;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
-(BOOL)appendStringAtLeft:(id)unkwnon
|
||||
withMapping:(char*)mapping
|
||||
{
|
||||
return NO;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
-(BOOL)compactHTMLTags
|
||||
{
|
||||
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;
|
||||
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];
|
||||
}
|
||||
[self _slowTakeValuesFromRequest:request inContext:context];
|
||||
} else {
|
||||
else
|
||||
[self _fastTakeValuesFromRequest:request inContext:context];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -36,74 +36,73 @@ RCS_ID("$Id$")
|
|||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
|
||||
static SEL prepareIterationSEL=NULL;
|
||||
static SEL objectAtIndexSEL = NULL;
|
||||
static SEL setValueInComponentSEL = NULL;
|
||||
|
||||
//====================================================================
|
||||
@implementation GSWRepetition
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GSWRepetition class])
|
||||
{
|
||||
prepareIterationSEL=@selector(_prepareIterationWithIndex:startIndex:stopIndex:list:listCount:listObjectAtIndexIMP:itemSetValueIMP:indexSetValueIMP:component:inContext:);
|
||||
objectAtIndexSEL=@selector(objectAtIndex:);
|
||||
setValueInComponentSEL=@selector(setValue:inComponent:);
|
||||
};
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
self = [super initWithName:nil associations:nil template: template];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
ASSIGN(_list, [associations objectForKey: list__Key]);
|
||||
ASSIGN(_item, [associations objectForKey: item__Key]);
|
||||
ASSIGN(_count, [associations objectForKey: count__Key]);
|
||||
ASSIGN(_index, [associations objectForKey: index__Key]);
|
||||
|
||||
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.",
|
||||
if ((self = [super initWithName:nil
|
||||
associations:nil
|
||||
template: template]))
|
||||
{
|
||||
ASSIGN(_list, [associations objectForKey: list__Key]);
|
||||
ASSIGN(_item, [associations objectForKey: item__Key]);
|
||||
ASSIGN(_count, [associations objectForKey: count__Key]);
|
||||
ASSIGN(_index, [associations objectForKey: index__Key]);
|
||||
|
||||
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 (_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__];
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
};
|
||||
|
@ -122,6 +121,7 @@ static SEL setValueInComponentSEL = NULL;
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%s %p list:%@ item:%@ count:%@ index:%@>",
|
||||
|
@ -130,72 +130,96 @@ static SEL setValueInComponentSEL = NULL;
|
|||
_list, _item, _count, _index];
|
||||
};
|
||||
|
||||
|
||||
|
||||
static inline void _prepareForIterationWithIndex(int i, int j, NSArray * array, GSWContext * context,
|
||||
GSWComponent *component, GSWAssociation* item, GSWAssociation* index)
|
||||
//--------------------------------------------------------------------
|
||||
static inline void _prepareForIterationWithIndex(BOOL isFirst,
|
||||
int i,
|
||||
int count,
|
||||
NSArray * list,
|
||||
IMP* oaiIMPPtr,
|
||||
GSWContext * context,
|
||||
GSWComponent *component,
|
||||
GSWAssociation* item,
|
||||
GSWAssociation* index)
|
||||
{
|
||||
if (item != nil) {
|
||||
id obj = [array objectAtIndex:i];
|
||||
[item _setValueNoValidation:obj
|
||||
inComponent:component];
|
||||
}
|
||||
if (index != nil) {
|
||||
[index _setValueNoValidation:[NSNumber numberWithInt:i]
|
||||
inComponent:component];
|
||||
}
|
||||
if (i != 0) {
|
||||
[context incrementLastElementIDComponent];
|
||||
} else {
|
||||
[context appendZeroElementIDComponent];
|
||||
}
|
||||
if (item != nil)
|
||||
{
|
||||
id obj = GSWeb_objectAtIndexWithImpPtr(list,oaiIMPPtr,i);
|
||||
[item _setValueNoValidation:obj
|
||||
inComponent:component];
|
||||
}
|
||||
if (index != nil)
|
||||
{
|
||||
[index _setValueNoValidation:GSWIntNumber(i)
|
||||
inComponent:component];
|
||||
}
|
||||
if (isFirst)
|
||||
GSWContext_appendZeroElementIDComponent(context);
|
||||
else
|
||||
GSWContext_incrementLastElementIDComponent(context);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
static inline void _cleanupAfterIteration(GSWContext * context,
|
||||
GSWComponent * component, int i, GSWAssociation* item, GSWAssociation* index)
|
||||
GSWComponent * component,
|
||||
int i,
|
||||
GSWAssociation* item,
|
||||
GSWAssociation* index)
|
||||
{
|
||||
if (item != nil) {
|
||||
[item _setValueNoValidation:nil
|
||||
inComponent:component];
|
||||
}
|
||||
if (index != nil) {
|
||||
[index _setValueNoValidation:[NSNumber numberWithInt:i]
|
||||
inComponent:component];
|
||||
}
|
||||
[context deleteLastElementIDComponent];
|
||||
if (item != nil)
|
||||
{
|
||||
[item _setValueNoValidation:nil
|
||||
inComponent:component];
|
||||
}
|
||||
if (index != nil)
|
||||
{
|
||||
[index _setValueNoValidation:GSWIntNumber(i)
|
||||
inComponent:component];
|
||||
}
|
||||
GSWContext_deleteLastElementIDComponent(context);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)appendToResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
NSArray * myArray = nil;
|
||||
NSNumber * countValue = nil;
|
||||
unsigned int count = 0;
|
||||
unsigned int i = 0;
|
||||
NSArray * list = nil;
|
||||
NSUInteger count = 0;
|
||||
NSUInteger i = 0;
|
||||
BOOL isFirst = YES;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
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];
|
||||
}
|
||||
if (_list != nil)
|
||||
{
|
||||
list = [_list valueInComponent:component];
|
||||
if (list != nil)
|
||||
count = [list count];
|
||||
}
|
||||
else
|
||||
{
|
||||
count = [[_count valueInComponent:component] intValue];
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
if (_startIndex != nil)
|
||||
i=[[_startIndex valueInComponent:component] intValue];
|
||||
|
||||
if (_stopIndex != nil)
|
||||
{
|
||||
NSUInteger stopIndex=[[_stopIndex valueInComponent:component] intValue];
|
||||
if (stopIndex<count)
|
||||
count=stopIndex+1;
|
||||
}
|
||||
|
||||
for (; i < count; i++)
|
||||
{
|
||||
_prepareForIterationWithIndex(isFirst, i, count, list, &oaiIMP, context, component,_item, _index);
|
||||
[super appendChildrenToResponse:response
|
||||
inContext:context];
|
||||
isFirst=NO;
|
||||
}
|
||||
|
||||
if (!isFirst)
|
||||
_cleanupAfterIteration(context, component, count, _item, _index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -212,130 +236,181 @@ static inline NSString* _indexStringForSenderAndElement(NSString * senderStr, NS
|
|||
// NSLog(@"elementLen:%d", elementLen);
|
||||
// NSLog(@"senderLen:%d", senderLen);
|
||||
|
||||
if (myRange.location == NSNotFound) {
|
||||
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;
|
||||
else
|
||||
{
|
||||
// NSLog(@"found myRange.location:%d", myRange.location);
|
||||
return [senderStr substringWithRange: NSMakeRange(elementLen, myRange.location-elementLen)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id <GSWActionResults>)invokeActionForRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
id <GSWActionResults, NSObject> element = nil;
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
NSString * indexStr = nil;
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (indexStr != nil) {
|
||||
int i = [indexStr intValue];
|
||||
if (_list != nil) {
|
||||
arrayValue = [_list valueInComponent:component];
|
||||
if (indexStr != nil)
|
||||
{
|
||||
int i = [indexStr intValue];
|
||||
if (_startIndex != nil)
|
||||
i+=[[_startIndex valueInComponent:component] intValue];
|
||||
|
||||
if (arrayValue != nil) {
|
||||
if ((i >= 0) && (i < [arrayValue count])) {
|
||||
currentValue = [arrayValue objectAtIndex:i];
|
||||
}
|
||||
if (_item != nil) {
|
||||
[_item _setValueNoValidation:currentValue
|
||||
inComponent:component];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_index != nil) {
|
||||
[_index _setValueNoValidation:[NSNumber numberWithInt:i]
|
||||
inComponent:component];
|
||||
}
|
||||
[context appendElementIDComponent: indexStr];
|
||||
if (_list != nil)
|
||||
{
|
||||
NSArray* list = [_list valueInComponent:component];
|
||||
|
||||
if (list != nil)
|
||||
{
|
||||
IMP oaiIMP=NULL;
|
||||
int stopIndex = 0;
|
||||
id currentValue = nil;
|
||||
NSUInteger count = [list count];
|
||||
if (_stopIndex)
|
||||
{
|
||||
stopIndex=[[_stopIndex valueInComponent:component] intValue];
|
||||
if (stopIndex<count)
|
||||
count=stopIndex+1;
|
||||
}
|
||||
if (i >= 0
|
||||
&& i < count)
|
||||
{
|
||||
currentValue = GSWeb_objectAtIndexWithImpPtr(list,&oaiIMP,i);
|
||||
}
|
||||
if (_item != nil)
|
||||
{
|
||||
[_item _setValueNoValidation:currentValue
|
||||
inComponent:component];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_index != nil)
|
||||
{
|
||||
[_index _setValueNoValidation:GSWIntNumber(i)
|
||||
inComponent:component];
|
||||
}
|
||||
GSWContext_appendElementIDComponent(context,indexStr);
|
||||
element = (id <GSWActionResults, NSObject>) [super invokeActionForRequest:request
|
||||
inContext:context];
|
||||
[context deleteLastElementIDComponent];
|
||||
} else {
|
||||
count = 0;
|
||||
|
||||
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);
|
||||
}
|
||||
inContext:context];
|
||||
GSWContext_deleteLastElementIDComponent(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOL isFirst=YES;
|
||||
NSUInteger count = 0;
|
||||
NSUInteger k = 0;
|
||||
NSArray* list = nil;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
if (_list != nil)
|
||||
{
|
||||
list = [_list valueInComponent:component];
|
||||
count = [list 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);
|
||||
}
|
||||
}
|
||||
if (_startIndex != nil)
|
||||
k=[[_startIndex valueInComponent:component] intValue];
|
||||
|
||||
if (_stopIndex != nil)
|
||||
{
|
||||
NSUInteger stopIndex=[[_stopIndex valueInComponent:component] intValue];
|
||||
if (stopIndex<count)
|
||||
count=stopIndex+1;
|
||||
}
|
||||
|
||||
for (k = 0; k < count && element == nil; k++) {
|
||||
_prepareForIterationWithIndex(k, count, arrayValue, context, component, _item, _index);
|
||||
element = (id <GSWActionResults, NSObject>) [super invokeActionForRequest:request
|
||||
inContext:context];
|
||||
|
||||
}
|
||||
for (; k < count && element == nil; k++)
|
||||
{
|
||||
_prepareForIterationWithIndex(isFirst,k, count, list, &oaiIMP, context, component, _item, _index);
|
||||
element = (id <GSWActionResults, NSObject>) [super invokeActionForRequest:request
|
||||
inContext:context];
|
||||
isFirst=NO;
|
||||
}
|
||||
|
||||
if (count > 0) {
|
||||
_cleanupAfterIteration(context, component, count, _item, _index);
|
||||
if (!isFirst)
|
||||
_cleanupAfterIteration(context, component, count, _item, _index);
|
||||
}
|
||||
}
|
||||
return element;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (void) takeValuesFromRequest:(GSWRequest *) request
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
NSArray * arrayValue = nil;
|
||||
id countValue = nil;
|
||||
int i = 0;
|
||||
NSArray * list = nil;
|
||||
NSUInteger i = 0;
|
||||
NSUInteger count = 0;
|
||||
BOOL isFirst = YES;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
int count = 0;
|
||||
|
||||
if (_list != nil) {
|
||||
arrayValue = [_list valueInComponent:component];
|
||||
if (arrayValue != nil) {
|
||||
count = [arrayValue count];
|
||||
if (_list != nil)
|
||||
{
|
||||
list = [_list valueInComponent:component];
|
||||
if (list != nil)
|
||||
count = [list 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 %@. Resetting to zero. (%@)",
|
||||
__PRETTY_FUNCTION__, component, _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);
|
||||
|
||||
if (_startIndex != nil)
|
||||
i=[[_startIndex valueInComponent:component] intValue];
|
||||
|
||||
if (_stopIndex != nil)
|
||||
{
|
||||
NSUInteger stopIndex=[[_stopIndex valueInComponent:component] intValue];
|
||||
if (stopIndex<count)
|
||||
count=stopIndex+1;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < count; i++) {
|
||||
|
||||
_prepareForIterationWithIndex(i, count, arrayValue, context, component,_item, _index);
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
_prepareForIterationWithIndex(isFirst, i, count, list, &oaiIMP, context, component,_item, _index);
|
||||
|
||||
[super takeValuesFromRequest:request
|
||||
inContext:context];
|
||||
isFirst=NO;
|
||||
}
|
||||
|
||||
[super takeValuesFromRequest:request
|
||||
inContext:context];
|
||||
|
||||
}
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
if (!isFirst)
|
||||
_cleanupAfterIteration(context, component, count, _item, _index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -56,9 +56,10 @@ RCS_ID("$Id$")
|
|||
{
|
||||
int i=0;
|
||||
NSMutableArray* qvs=[NSMutableArray array];
|
||||
IMP oaiIMP=NULL;
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
NSString* string=[valuesAndQualities objectAtIndex:i];
|
||||
NSString* string=GSWeb_objectAtIndexWithImpPtr(valuesAndQualities,&oaiIMP,i);
|
||||
GSWValueQualityHeaderPart* qv=[GSWValueQualityHeaderPart
|
||||
valueQualityHeaderPartWithString:string];
|
||||
if ([[qv value]length]>0)
|
||||
|
@ -68,6 +69,7 @@ RCS_ID("$Id$")
|
|||
if (count>0)
|
||||
{
|
||||
unsigned int i;
|
||||
IMP oaiIMP=NULL;
|
||||
//Sor oon quality desc
|
||||
[qvs sortUsingSelector:@selector(compareOnQualityDesc:)];
|
||||
|
||||
|
@ -75,11 +77,11 @@ RCS_ID("$Id$")
|
|||
for(i=0;i<count;i++)
|
||||
{
|
||||
int j=0;
|
||||
GSWValueQualityHeaderPart* qv=[qvs objectAtIndex:i];
|
||||
GSWValueQualityHeaderPart* qv=GSWeb_objectAtIndexWithImpPtr(qvs,&oaiIMP,i);
|
||||
NSString* value=[qv value];
|
||||
for(j=i+1;j<count;j++)
|
||||
{
|
||||
GSWValueQualityHeaderPart* qv2=[qvs objectAtIndex:j];
|
||||
GSWValueQualityHeaderPart* qv2=GSWeb_objectAtIndexWithImpPtr(qvs,&oaiIMP,j);
|
||||
NSString* value2=[qv2 value];
|
||||
if ([value2 isEqual:value])
|
||||
{
|
||||
|
@ -536,6 +538,7 @@ RCS_ID("$Id$")
|
|||
//Remove Duplicates
|
||||
int i=0;
|
||||
int browserLanguagesCount=0;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
browserLanguages=[[browserLanguages mutableCopy] autorelease];
|
||||
browserLanguagesCount=[browserLanguages count];
|
||||
|
@ -543,10 +546,10 @@ RCS_ID("$Id$")
|
|||
for(i=0;i<browserLanguagesCount;i++)
|
||||
{
|
||||
int j=0;
|
||||
NSString* language=[browserLanguages objectAtIndex:i];
|
||||
NSString* language=GSWeb_objectAtIndexWithImpPtr(browserLanguages,&oaiIMP,i);
|
||||
for(j=browserLanguagesCount-1;j>i;j--)
|
||||
{
|
||||
NSString* language2=[browserLanguages objectAtIndex:j];
|
||||
NSString* language2=GSWeb_objectAtIndexWithImpPtr(browserLanguages,&oaiIMP,j);
|
||||
if ([language2 isEqual:language])
|
||||
{
|
||||
[browserLanguages removeObjectAtIndex:j];
|
||||
|
@ -1005,9 +1008,10 @@ RCS_ID("$Id$")
|
|||
id cookieValue=nil;
|
||||
int index=0;
|
||||
int valueCount=[value count];
|
||||
IMP oaiIMP=NULL;
|
||||
for(index=0;index<valueCount;index++)
|
||||
{
|
||||
cookieValue=[value objectAtIndex:index];
|
||||
cookieValue=GSWeb_objectAtIndexWithImpPtr(value,&oaiIMP,index);
|
||||
if (cookieValue)
|
||||
{
|
||||
newValue=nil;
|
||||
|
@ -1086,11 +1090,12 @@ RCS_ID("$Id$")
|
|||
NSArray* cookiePrevValue=nil;
|
||||
int i=0;
|
||||
int cookiesArrayCount=[cookiesArray count];
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
for(i=0;i<cookiesArrayCount;i++)
|
||||
{
|
||||
int cookieCount=0;
|
||||
cookieString=[cookiesArray objectAtIndex:i];
|
||||
cookieString=GSWeb_objectAtIndexWithImpPtr(cookiesArray,&oaiIMP,i);
|
||||
cookie=[cookieString componentsSeparatedByString:@"="];
|
||||
|
||||
cookieCount=[cookie count];
|
||||
|
@ -1282,9 +1287,10 @@ RCS_ID("$Id$")
|
|||
NSString* key=nil;
|
||||
BOOL ismapCoordsFound=NO;
|
||||
NSArray* value=nil;
|
||||
IMP oaiIMP=NULL;
|
||||
for(i=0;i<allKeysCount && !ismapCoordsFound;i++)
|
||||
{
|
||||
key=[allKeys objectAtIndex:i];
|
||||
key=GSWeb_objectAtIndexWithImpPtr(allKeys,&oaiIMP,i);
|
||||
value=[tmpFormData objectForKey:key];
|
||||
if ([value count]==1
|
||||
&&[[value objectAtIndex:0]length]==0
|
||||
|
@ -1557,6 +1563,7 @@ RCS_ID("$Id$")
|
|||
NSArray* value=[headers objectForKey:key];
|
||||
int i=0;
|
||||
int count=[value count];
|
||||
IMP oaiIMP=NULL;
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
// append "key: value\n" to headersString
|
||||
|
@ -1568,7 +1575,7 @@ RCS_ID("$Id$")
|
|||
@": ");
|
||||
GSWeb_appendStringWithImpPtr(headersString,
|
||||
&headersString_appendStringIMP,
|
||||
[value objectAtIndex:i]);
|
||||
GSWeb_objectAtIndexWithImpPtr(value,&oaiIMP,i));
|
||||
GSWeb_appendStringWithImpPtr(headersString,
|
||||
&headersString_appendStringIMP,
|
||||
@"\n");
|
||||
|
@ -1628,9 +1635,10 @@ RCS_ID("$Id$")
|
|||
{
|
||||
int i=0;
|
||||
int count=[content count];
|
||||
IMP oaiIMP=NULL;
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
GSMimeDocument* aDoc=[content objectAtIndex:i];
|
||||
GSMimeDocument* aDoc=GSWeb_objectAtIndexWithImpPtr(content,&oaiIMP,i);
|
||||
GSMimeHeader* contentDispositionHeader=nil;
|
||||
NSString* contentDispositionValue=nil;
|
||||
NSDictionary* contentDispositionParams=nil;
|
||||
|
@ -1728,18 +1736,19 @@ RCS_ID("$Id$")
|
|||
int i=0;
|
||||
NSData* tmpData=nil;
|
||||
int partsCount=0;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
boundaryString=[NSString stringWithFormat:@"--%@\r\n",aBoundary];//Add "--" and "\r\n"
|
||||
dataBoundary=[boundaryString dataUsingEncoding:[self formValueEncoding]];//TODO
|
||||
parts=[aBody componentsSeparatedByData:dataBoundary];
|
||||
|
||||
partsCount=[parts count];
|
||||
|
||||
for(i=0;i<partsCount;i++)
|
||||
{
|
||||
tmpData=[parts objectAtIndex:i];
|
||||
tmpData=GSWeb_objectAtIndexWithImpPtr(parts,&oaiIMP,i);
|
||||
if ([tmpData length]<400)
|
||||
{
|
||||
//TODO: we don't user dataString ?
|
||||
NSString* _dataString=nil;
|
||||
_dataString=[[[NSString alloc]initWithData:tmpData
|
||||
encoding:[self formValueEncoding]]autorelease];
|
||||
|
@ -1747,7 +1756,7 @@ RCS_ID("$Id$")
|
|||
else
|
||||
{
|
||||
//NSDebugMLLog(@"requests",@"tmpData=%@",tmpData);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// The 1st part should be empty (or it's only a warning message...)
|
||||
|
@ -1759,9 +1768,10 @@ RCS_ID("$Id$")
|
|||
|
||||
// Now deleting last \r\n of each object
|
||||
parts=[parts mutableCopy];
|
||||
oaiIMP=NULL;
|
||||
for(i=0;i<partsCount;i++)
|
||||
{
|
||||
tmpData=[parts objectAtIndex:i];
|
||||
tmpData=GSWeb_objectAtIndexWithImpPtr(parts,&oaiIMP,i);
|
||||
if (i==partsCount-1)
|
||||
{
|
||||
//Delete the last \r\nseparator--\r\n
|
||||
|
@ -1779,7 +1789,7 @@ RCS_ID("$Id$")
|
|||
|
||||
for(i=0;i<partsCount;i++)
|
||||
{
|
||||
tmpData=[parts objectAtIndex:i];
|
||||
tmpData=GSWeb_objectAtIndexWithImpPtr(parts,&oaiIMP,i);
|
||||
if ([tmpData length]<400)
|
||||
{
|
||||
NSString* dataString=nil;
|
||||
|
@ -1911,6 +1921,7 @@ into
|
|||
int partIndex=0;
|
||||
int partCount=0;
|
||||
NSString* part=nil;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
parsedParts=(NSMutableDictionary*)[NSMutableDictionary dictionary];
|
||||
headerParts=[aHeader componentsSeparatedByString:@";"];
|
||||
|
@ -1921,7 +1932,7 @@ into
|
|||
int parsedPartCount=0;
|
||||
NSString* key=nil;
|
||||
NSString* value=nil;
|
||||
part=[headerParts objectAtIndex:partIndex];
|
||||
part=GSWeb_objectAtIndexWithImpPtr(headerParts,&oaiIMP,partIndex);
|
||||
part=[part stringByTrimmingSpaces];
|
||||
parsedPart=[part componentsSeparatedByString:@"="];
|
||||
parsedPartCount=[parsedPart count];
|
||||
|
|
|
@ -32,16 +32,8 @@
|
|||
#ifndef _GSWResetButton_h__
|
||||
#define _GSWResetButton_h__
|
||||
|
||||
//OK
|
||||
//====================================================================
|
||||
@interface GSWResetButton: GSWInput
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
contentElements:(NSArray*)elements;
|
||||
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
|
|
@ -38,19 +38,10 @@ RCS_ID("$Id$")
|
|||
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
contentElements:(NSArray*)elements
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
|
||||
|
||||
[tmpAssociations setObject:[GSWAssociation associationWithValue:@"reset"]
|
||||
forKey:@"type"];
|
||||
|
||||
if (![tmpAssociations objectForKey:value__Key])
|
||||
[tmpAssociations setObject:[GSWAssociation associationWithValue:@"reset"]
|
||||
forKey:value__Key];
|
||||
|
||||
if ((self=[super initWithName:aName
|
||||
associations:tmpAssociations
|
||||
if ((self=[super initWithName:@"input"
|
||||
associations:associations
|
||||
contentElements:nil]))
|
||||
{
|
||||
};
|
||||
|
@ -58,6 +49,12 @@ RCS_ID("$Id$")
|
|||
return self;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSString*) type
|
||||
{
|
||||
return @"reset";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)context
|
||||
|
@ -67,4 +64,10 @@ RCS_ID("$Id$")
|
|||
//Does Nothing and don't call its parent GSWInput !
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendCloseTagToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
#include <GNUstepBase/NSObject+GNUstepBase.h>
|
||||
#include <GNUstepBase/NSData+GNUstepBase.h>
|
||||
#include <GNUstepBase/NSString+GNUstepBase.h>
|
||||
|
@ -912,25 +913,22 @@ extern id gcObjectsToBeVisited;
|
|||
-(NSString*)_contextIDMatchingIDsInContext:(GSWContext*)aContext
|
||||
{
|
||||
NSString* contextID=nil;
|
||||
NSString* requestContextID=nil;
|
||||
|
||||
requestContextID=[aContext _requestContextID];
|
||||
NSString* requestContextID=[aContext _requestContextID];
|
||||
if (_contextRecords && requestContextID)
|
||||
{
|
||||
NSArray* contextIDs = [_contextRecords allKeys];
|
||||
int count = [contextIDs count];
|
||||
int i=0;
|
||||
IMP oaiIMP=NULL;
|
||||
for(i=0;!contextID && i<count;i++)
|
||||
{
|
||||
NSString* aContextID=[contextIDs objectAtIndex:i];
|
||||
NSString* aContextID=GSWeb_objectAtIndexWithImpPtr(contextIDs,&oaiIMP,i);
|
||||
GSWTransactionRecord* aTransactionRecord=[_contextRecords objectForKey:aContextID];
|
||||
if ([aTransactionRecord isMatchingIDsInContext:aContext])
|
||||
contextID=aContextID;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return contextID;
|
||||
}
|
||||
|
||||
|
@ -938,7 +936,6 @@ extern id gcObjectsToBeVisited;
|
|||
// _rearrangeContextArrayStack in wo 5
|
||||
-(void)_rearrangeContextArrayStackForContextID:(NSString*)contextID
|
||||
{
|
||||
|
||||
if (_contextRecords)
|
||||
{
|
||||
NSUInteger stackIndex=0;
|
||||
|
@ -968,9 +965,10 @@ extern id gcObjectsToBeVisited;
|
|||
NSMutableArray* contextArray=nil;
|
||||
NSUInteger stackCount=[_contextArrayStack count];
|
||||
NSUInteger i=0;
|
||||
IMP oaiIMP=NULL;
|
||||
for(i=0;!contextArray && i<stackCount;i++)
|
||||
{
|
||||
NSMutableArray* aContextArray=[_contextArrayStack objectAtIndex:i];
|
||||
NSMutableArray* aContextArray=GSWeb_objectAtIndexWithImpPtr(_contextArrayStack,&oaiIMP,i);
|
||||
NSUInteger contextArrayIndex=[aContextArray indexOfObject:aContextID];
|
||||
if (contextArrayIndex!=NSNotFound)
|
||||
{
|
||||
|
@ -1177,8 +1175,6 @@ Returns first element of languages or nil if languages is empty
|
|||
if ([languages count]>0)
|
||||
firstLanguage=[languages objectAtIndex:0];
|
||||
|
||||
|
||||
|
||||
return firstLanguage;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,34 +53,45 @@ static Class standardClass = Nil;
|
|||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
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 ((self = [super initWithName:nil
|
||||
associations:nil
|
||||
template: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))) {
|
||||
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Cannot have 'dateFormat' and 'numberFormat' attributes at the same time.",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
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))
|
||||
{
|
||||
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Cannot have 'dateFormat' and 'numberFormat' attributes at the same time.",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -115,10 +126,8 @@ static Class standardClass = Nil;
|
|||
//--------------------------------------------------------------------
|
||||
|
||||
// TODO: put that into a superclass, bulid a cache?
|
||||
|
||||
-(NSFormatter*)formatterForComponent:(GSWComponent*)component
|
||||
{
|
||||
//OK
|
||||
id formatValue = nil;
|
||||
id formatter = nil;
|
||||
if (_dateFormat)
|
||||
|
@ -153,54 +162,56 @@ static Class standardClass = Nil;
|
|||
inContext:(GSWContext*)context
|
||||
{
|
||||
GSWComponent* component = GSWContext_component(context);
|
||||
NSString* formattedValue=nil;
|
||||
id valueValue = 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 (_value == nil)
|
||||
{
|
||||
NSLog(@"%s:WARNING value binding is nil!", __PRETTY_FUNCTION__);
|
||||
}
|
||||
if (formattedValue == nil) {
|
||||
formattedValue = valueValue;
|
||||
}
|
||||
|
||||
} else {
|
||||
NSLog(@"%s:WARNING value binding is nil!", __PRETTY_FUNCTION__);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString* formattedValue=nil;
|
||||
id valueValue = [_value valueInComponent:component];
|
||||
if (_shouldFormat)
|
||||
{
|
||||
NSFormatter* formatter=[self formatterForComponent:component];
|
||||
if (formatter != nil)
|
||||
{
|
||||
NS_DURING
|
||||
{
|
||||
formattedValue=NSStringWithObject([formatter stringForObjectValue:valueValue]);
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
formattedValue = nil;
|
||||
NSLog(@"%s: value '%@' of class '%@' cannot be formatted.",
|
||||
__PRETTY_FUNCTION__, valueValue, [valueValue class]);
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
}
|
||||
else
|
||||
formattedValue=NSStringWithObject(valueValue);
|
||||
|
||||
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);
|
||||
}
|
||||
if ((formattedValue == nil || [formattedValue length] == 0)
|
||||
&& _valueWhenEmpty != nil)
|
||||
{
|
||||
formattedValue = [_valueWhenEmpty valueInComponent:component];
|
||||
GSWResponse_appendContentString(response, formattedValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (formattedValue != nil)
|
||||
{
|
||||
BOOL flag = YES;
|
||||
if (_escapeHTML != nil)
|
||||
flag = [_escapeHTML boolValueInComponent:component];
|
||||
if (flag)
|
||||
GSWResponse_appendContentHTMLConvertString(response, formattedValue);
|
||||
else
|
||||
GSWResponse_appendContentString(response, formattedValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@end
|
||||
|
|
|
@ -36,42 +36,51 @@ RCS_ID("$Id$")
|
|||
//====================================================================
|
||||
@implementation GSWSubmitButton
|
||||
|
||||
static GSWAssociation* static_defaultValueAssociation = nil;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
+ (void) initialize
|
||||
{
|
||||
if (self == [GSWSubmitButton class])
|
||||
{
|
||||
if (!static_defaultValueAssociation)
|
||||
{
|
||||
ASSIGN(static_defaultValueAssociation,([GSWAssociation associationWithValue:@"Submit"]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
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 ((self = [super initWithName:@"input"
|
||||
associations:associations
|
||||
template: nil]))
|
||||
{
|
||||
if (_value == nil)
|
||||
ASSIGN(_value,static_defaultValueAssociation);
|
||||
|
||||
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__];
|
||||
}
|
||||
|
||||
GSWAssignAndRemoveAssociation(&_action,_associations,action__Key);
|
||||
GSWAssignAndRemoveAssociation(&_actionClass,_associations,actionClass__Key);
|
||||
GSWAssignAndRemoveAssociation(&_directActionName,_associations,directActionName__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__];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
};
|
||||
|
||||
|
@ -84,11 +93,13 @@ RCS_ID("$Id$")
|
|||
[super dealloc];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSString*) type
|
||||
{
|
||||
return @"submit";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id) description
|
||||
{
|
||||
return [NSString stringWithFormat:@"<%s %p action: %@ actionClass: %@ directActionName:%@ disabled:%@ >",
|
||||
|
@ -105,78 +116,95 @@ RCS_ID("$Id$")
|
|||
//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];
|
||||
}
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
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");
|
||||
[localException raise];
|
||||
{
|
||||
localException=ExceptionByAddingUserInfoObjectFrameInfo(localException,
|
||||
@"In GSWSubmitButton invokeActionForRequest:inContext");
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
|
||||
return actionValue;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// PRIVATE used within dynamic elements
|
||||
- (NSString*) _actionClassAndNameInContext:(GSWContext*) context
|
||||
{
|
||||
NSString * s = [self computeActionStringWithActionClassAssociation: _actionClass
|
||||
directActionNameAssociation: _directActionName
|
||||
inContext: context];
|
||||
|
||||
return s;
|
||||
return [self computeActionStringWithActionClassAssociation: _actionClass
|
||||
directActionNameAssociation: _directActionName
|
||||
inContext: context];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (void) _appendNameAttributeToResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)context
|
||||
{
|
||||
if ((_directActionName != nil) || (_actionClass != nil)) {
|
||||
[response _appendTagAttribute: name__Key
|
||||
value: [self _actionClassAndNameInContext:context]
|
||||
escapingHTMLAttributeValue: NO];
|
||||
} else {
|
||||
[super _appendNameAttributeToResponse:response
|
||||
inContext: context];
|
||||
}
|
||||
if (_directActionName != nil
|
||||
|| _actionClass != nil)
|
||||
{
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
name__Key,
|
||||
[self _actionClassAndNameInContext:context],
|
||||
NO);
|
||||
}
|
||||
else
|
||||
{
|
||||
[super _appendNameAttributeToResponse:response
|
||||
inContext: context];
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
- (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,'>');
|
||||
}
|
||||
if (_directActionName != nil
|
||||
|| _actionClass != nil)
|
||||
{
|
||||
GSWResponse_appendContentAsciiString(response,@"<input type=\"hidden\" name=\"WOSubmitAction\"");
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response,
|
||||
value__Key,
|
||||
[self _actionClassAndNameInContext:context],
|
||||
NO);
|
||||
GSWResponse_appendContentCharacter(response,'>');
|
||||
}
|
||||
}
|
||||
|
||||
-(void) _appendCloseTagToResponse:(GSWResponse *) response
|
||||
|
|
|
@ -41,29 +41,32 @@ RCS_ID("$Id$")
|
|||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)templateElement
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
if ((self=[super initWithName:aName
|
||||
associations:associations
|
||||
if ((self=[super initWithName:nil
|
||||
associations:nil
|
||||
template:nil]))
|
||||
{
|
||||
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
|
||||
|
||||
[tmpAssociations removeObjectForKey:GSWComponentName__Key[GSWebNamingConv]];
|
||||
|
||||
[tmpAssociations removeObjectForKey:componentName__Key];
|
||||
|
||||
_componentName = [[associations objectForKey:GSWComponentName__Key[GSWebNamingConv]
|
||||
withDefaultObject:[_componentName autorelease]] retain];
|
||||
ASSIGN(_componentName,([associations objectForKey:GSWComponentName__Key[GSWebNamingConv]]));
|
||||
if (_componentName)
|
||||
[tmpAssociations removeObjectForKey:GSWComponentName__Key[GSWebNamingConv]];
|
||||
else
|
||||
{
|
||||
ASSIGN(_componentName,([associations objectForKey:componentName__Key]));
|
||||
if (_componentName)
|
||||
[tmpAssociations removeObjectForKey:componentName__Key];
|
||||
else
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Missing required attribute: '%@'",
|
||||
__PRETTY_FUNCTION__,GSWComponentName__Key[GSWebNamingConv]];
|
||||
}
|
||||
}
|
||||
|
||||
if (!_componentName)
|
||||
{
|
||||
_componentName = [[associations objectForKey:componentName__Key
|
||||
withDefaultObject:[_componentName autorelease]] retain];
|
||||
}
|
||||
|
||||
ASSIGN(_componentAttributes,[NSDictionary dictionaryWithDictionary:tmpAssociations]);
|
||||
ASSIGN(_template,templateElement);
|
||||
ASSIGN(_componentAttributes,tmpAssociations);
|
||||
ASSIGN(_template,template);
|
||||
|
||||
_componentCache=[NSMutableDictionary new];
|
||||
};
|
||||
|
@ -88,81 +91,19 @@ RCS_ID("$Id$")
|
|||
(void*)self];
|
||||
};
|
||||
|
||||
@end
|
||||
|
||||
//====================================================================
|
||||
@implementation GSWSwitchComponent (GSWSwitchComponentA)
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)appendToResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)aContext
|
||||
//--------------------------------------------------------------------
|
||||
/** returns the element name by resolving _componentName association **/
|
||||
-(NSString*)_elementNameInContext:(GSWContext*)aContext
|
||||
{
|
||||
GSWElement* element=nil;
|
||||
NSString* elementNameInContext=nil;
|
||||
|
||||
GSWStartElement(aContext);
|
||||
GSWSaveAppendToResponseElementID(aContext);
|
||||
elementNameInContext=[self _elementNameInContext:aContext];
|
||||
GSWContext_appendElementIDComponent(aContext,elementNameInContext);
|
||||
if ([elementNameInContext length]==0)
|
||||
GSWComponent* component=GSWContext_component(aContext);
|
||||
NSString* componentName=NSStringWithObject([_componentName valueInComponent:component]);
|
||||
if ([componentName length]==0)
|
||||
{
|
||||
ExceptionRaise(@"GSWSwitchComponent",@"ComponentName Value is null ! componentName: %@",
|
||||
_componentName);
|
||||
};
|
||||
element=[self _realComponentWithName:elementNameInContext
|
||||
inContext:aContext];
|
||||
[element appendToResponse:response
|
||||
inContext:aContext];
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
id <GSWActionResults, NSObject> resultElement=nil;
|
||||
GSWElement* element=nil;
|
||||
NSString* elementNameInContext=nil;
|
||||
|
||||
GSWStartElement(aContext);
|
||||
GSWAssertCorrectElementID(aContext);
|
||||
elementNameInContext=[self _elementNameInContext:aContext];
|
||||
GSWContext_appendElementIDComponent(aContext,elementNameInContext);
|
||||
if ([elementNameInContext length]==0)
|
||||
{
|
||||
ExceptionRaise(@"GSWSwitchComponent",@"ComponentName Value is null ! componentName: %@",
|
||||
_componentName);
|
||||
};
|
||||
element=[self _realComponentWithName:elementNameInContext
|
||||
inContext:aContext];
|
||||
resultElement = (id <GSWActionResults, NSObject>) [element invokeActionForRequest:request
|
||||
inContext:aContext];
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
|
||||
return resultElement;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)aRequest
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
GSWElement* element=nil;
|
||||
NSString* elementNameInContext=nil;
|
||||
|
||||
GSWStartElement(aContext);
|
||||
GSWAssertCorrectElementID(aContext);
|
||||
elementNameInContext=[self _elementNameInContext:aContext];
|
||||
GSWContext_appendElementIDComponent(aContext,elementNameInContext);
|
||||
if ([elementNameInContext length]==0)
|
||||
{
|
||||
ExceptionRaise(@"GSWSwitchComponent",@"ComponentName Value is null ! componentName: %@",
|
||||
_componentName);
|
||||
};
|
||||
element=[self _realComponentWithName:elementNameInContext
|
||||
inContext:aContext];
|
||||
[element takeValuesFromRequest:aRequest
|
||||
inContext:aContext];
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s: componentName not specified or evaluate to nil or empty",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
return componentName;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -173,23 +114,19 @@ if the component has already been created, it get it from the cache; otherwise,
|
|||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
GSWElement* element=nil;
|
||||
NSArray* languages=nil;
|
||||
GSWComponent* component=nil;
|
||||
|
||||
component=GSWContext_component(aContext);
|
||||
|
||||
if ([aName length]==0)
|
||||
{
|
||||
ExceptionRaise(@"GSWSwitchComponent",
|
||||
@"ComponentName is null. componentNameKey='%@' declarationName=%@ currentComponentName=%@",
|
||||
_componentName,[self declarationName],[component name]);
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s: no componentName",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
else
|
||||
{
|
||||
element=[_componentCache objectForKey:aName];
|
||||
if (!element)
|
||||
if (element==nil)
|
||||
{
|
||||
languages=[aContext languages];
|
||||
NSArray* languages=[aContext languages];
|
||||
element=[GSWApp dynamicElementWithName:aName
|
||||
associations:_componentAttributes
|
||||
template:_template
|
||||
|
@ -201,9 +138,9 @@ if the component has already been created, it get it from the cache; otherwise,
|
|||
}
|
||||
else
|
||||
{
|
||||
ExceptionRaise(@"GSWSwitchComponent",
|
||||
@"GSWSwitchComponent %p (declarationName=%@): Creation failed for element named:%@",
|
||||
self,[self declarationName],aName);
|
||||
[NSException raise:NSInternalInconsistencyException
|
||||
format:@"%s: cannot find component or dynamic element named %@",
|
||||
__PRETTY_FUNCTION__,aName];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -211,18 +148,88 @@ if the component has already been created, it get it from the cache; otherwise,
|
|||
return element;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
/** returns the element name by resolving _componentName association **/
|
||||
-(NSString*)_elementNameInContext:(GSWContext*)aContext
|
||||
//--------------------------------------------------------------------
|
||||
-(void)takeValuesFromRequest:(GSWRequest*)aRequest
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
GSWComponent* component=nil;
|
||||
NSString* componentNameValue=nil;
|
||||
GSWElement* element=nil;
|
||||
NSString* elementNameInContext=nil;
|
||||
|
||||
component=GSWContext_component(aContext);
|
||||
GSWStartElement(aContext);
|
||||
GSWAssertCorrectElementID(aContext);
|
||||
|
||||
componentNameValue=[_componentName valueInComponent:component];
|
||||
elementNameInContext=[self _elementNameInContext:aContext];
|
||||
|
||||
return componentNameValue;
|
||||
GSWContext_appendElementIDComponent(aContext,elementNameInContext);
|
||||
|
||||
if ([elementNameInContext length]==0)
|
||||
{
|
||||
ExceptionRaise(@"GSWSwitchComponent",@"ComponentName Value is null ! componentName: %@",
|
||||
_componentName);
|
||||
};
|
||||
element=[self _realComponentWithName:elementNameInContext
|
||||
inContext:aContext];
|
||||
[element takeValuesFromRequest:aRequest
|
||||
inContext:aContext];
|
||||
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
id <GSWActionResults, NSObject> resultElement=nil;
|
||||
GSWElement* element=nil;
|
||||
NSString* elementNameInContext=nil;
|
||||
|
||||
GSWStartElement(aContext);
|
||||
GSWAssertCorrectElementID(aContext);
|
||||
|
||||
elementNameInContext=[self _elementNameInContext:aContext];
|
||||
|
||||
GSWContext_appendElementIDComponent(aContext,elementNameInContext);
|
||||
|
||||
if ([elementNameInContext length]==0)
|
||||
{
|
||||
ExceptionRaise(@"GSWSwitchComponent",@"ComponentName Value is null ! componentName: %@",
|
||||
_componentName);
|
||||
};
|
||||
|
||||
element=[self _realComponentWithName:elementNameInContext
|
||||
inContext:aContext];
|
||||
resultElement = (id <GSWActionResults, NSObject>) [element invokeActionForRequest:request
|
||||
inContext:aContext];
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
|
||||
return resultElement;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)appendToResponse:(GSWResponse*)response
|
||||
inContext:(GSWContext*)aContext
|
||||
{
|
||||
GSWElement* element=nil;
|
||||
NSString* elementNameInContext=nil;
|
||||
|
||||
GSWStartElement(aContext);
|
||||
GSWSaveAppendToResponseElementID(aContext);
|
||||
|
||||
elementNameInContext=[self _elementNameInContext:aContext];
|
||||
|
||||
GSWContext_appendElementIDComponent(aContext,elementNameInContext);
|
||||
|
||||
if ([elementNameInContext length]==0)
|
||||
{
|
||||
ExceptionRaise(@"GSWSwitchComponent",@"ComponentName Value is null ! componentName: %@",
|
||||
_componentName);
|
||||
};
|
||||
element=[self _realComponentWithName:elementNameInContext
|
||||
inContext:aContext];
|
||||
[element appendToResponse:response
|
||||
inContext:aContext];
|
||||
|
||||
GSWContext_deleteLastElementIDComponent(aContext);
|
||||
};
|
||||
|
||||
@end
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
#include <GNUstepBase/NSString+GNUstepBase.h>
|
||||
#include <GNUstepBase/NSObject+GNUstepBase.h>
|
||||
|
||||
|
@ -387,6 +388,7 @@ Method for GSWDeclarationParserPragmaDelegate protocol
|
|||
NSString* path=nil;
|
||||
int iLanguage=0;
|
||||
BOOL isPathAlreadyProcessed=NO;
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
resourceManager=[GSWApp resourceManager];
|
||||
|
||||
|
@ -407,7 +409,7 @@ Method for GSWDeclarationParserPragmaDelegate protocol
|
|||
NSString* language=nil;
|
||||
int iName=0;
|
||||
if (iLanguage<[_languages count])
|
||||
language=[_languages objectAtIndex:iLanguage];
|
||||
language=GSWeb_objectAtIndexWithImpPtr(_languages,&oaiIMP,iLanguage);
|
||||
else
|
||||
language=nil;
|
||||
for(iName=0;!path && iName<2;iName++)
|
||||
|
@ -475,23 +477,23 @@ Method for GSWDeclarationParserPragmaDelegate protocol
|
|||
if (!declarations)
|
||||
{
|
||||
ExceptionRaise(@"%@ Template componentDeclaration parse failed for "
|
||||
@"included file:%@ in framework:%@ (processedFiles=%@) error=%@",
|
||||
@"included file:%@ in framework:%@ (processedFiles=%@)",
|
||||
[self logPrefix],
|
||||
declarationFileName,
|
||||
declarationFrameworkName,
|
||||
_processedDeclarationsFilePaths,
|
||||
error);
|
||||
_processedDeclarationsFilePaths);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
ExceptionRaise(@"GSWTemplateParser",
|
||||
@"%@ Can't load included component declaration "
|
||||
@"named:%@ in framework:%@ (_processedDeclarationsFilePaths=%@)",
|
||||
@"named:%@ in framework:%@ (_processedDeclarationsFilePaths=%@) error=%@",
|
||||
[self logPrefix],
|
||||
declarationFileName,
|
||||
declarationFrameworkName,
|
||||
_processedDeclarationsFilePaths);
|
||||
_processedDeclarationsFilePaths,
|
||||
error);
|
||||
};
|
||||
}
|
||||
else if (isPathAlreadyProcessed)
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
|
||||
//====================================================================
|
||||
@implementation GSWTemporaryElement
|
||||
|
@ -143,10 +144,10 @@ RCS_ID("$Id$")
|
|||
// More than one child: try to concatenate BareStrings
|
||||
NSMutableString* bareStringText=nil;
|
||||
int i=0;
|
||||
|
||||
IMP oaiIMP=NULL;
|
||||
for(i=0;i<childrenCount;i++)
|
||||
{
|
||||
GSWElement* element=[_children objectAtIndex:i];
|
||||
GSWElement* element=GSWeb_objectAtIndexWithImpPtr(_children,&oaiIMP,i);
|
||||
if ([element isKindOfClass:[GSWHTMLBareString class]])// Concatenate BareStrings
|
||||
{
|
||||
if (bareStringText)
|
||||
|
@ -155,7 +156,8 @@ RCS_ID("$Id$")
|
|||
element=nil;
|
||||
}
|
||||
else if (i+1<childrenCount
|
||||
&& [[_children objectAtIndex:i+1] isKindOfClass:[GSWHTMLBareString class]])
|
||||
&& [GSWeb_objectAtIndexWithImpPtr(_children,&oaiIMP,i+1)
|
||||
isKindOfClass:[GSWHTMLBareString class]])
|
||||
{
|
||||
bareStringText=[NSMutableString stringWithString:[(GSWHTMLBareString*)element string]];
|
||||
element=nil;
|
||||
|
|
|
@ -41,26 +41,21 @@ RCS_ID("$Id$")
|
|||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
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__];
|
||||
}
|
||||
|
||||
if ((self = [super initWithName:@"textarea"
|
||||
associations:associations
|
||||
template: 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
|
||||
{
|
||||
[super dealloc];
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(NSString*)description
|
||||
{
|
||||
|
@ -75,64 +70,68 @@ RCS_ID("$Id$")
|
|||
return @"textarea";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(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) {
|
||||
[_value setValue: [request stringFormValueForKey: nameCtx]
|
||||
inComponent:component];
|
||||
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!
|
||||
// nothing!
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Replace \r\n by \n
|
||||
-(NSString*)_filterSoftReturnsFromString:(NSString*)string
|
||||
{
|
||||
NSRange range;
|
||||
NSMutableString * myTmpStr = nil;
|
||||
unsigned len = 0;
|
||||
NSString* result=nil;
|
||||
|
||||
if (!string) {
|
||||
return nil;
|
||||
}
|
||||
len = [string length];
|
||||
if (len<1) {
|
||||
return string;
|
||||
}
|
||||
|
||||
myTmpStr = [NSMutableString stringWithCapacity: len];
|
||||
[myTmpStr setString: string];
|
||||
if (string!=nil)
|
||||
{
|
||||
NSUInteger len = [string length];
|
||||
if (len==0)
|
||||
result=string;
|
||||
else
|
||||
{
|
||||
NSMutableString * myTmpStr = [NSMutableString stringWithString: string];
|
||||
|
||||
while (YES) {
|
||||
range = [myTmpStr rangeOfString:@"\r\n"];
|
||||
if (range.length>0) {
|
||||
[myTmpStr replaceCharactersInRange: range withString:@"\n"];
|
||||
} else {
|
||||
break;
|
||||
while (YES)
|
||||
{
|
||||
NSRange range = [myTmpStr rangeOfString:@"\r\n"];
|
||||
if (range.length>0)
|
||||
[myTmpStr replaceCharactersInRange: range withString:@"\n"];
|
||||
else
|
||||
break;
|
||||
}
|
||||
result=[NSString stringWithString: myTmpStr];
|
||||
}
|
||||
}
|
||||
}
|
||||
return [NSString stringWithString: myTmpStr];
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) appendChildrenToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
id valueValue = [_value valueInComponent:GSWContext_component(context)];
|
||||
if (valueValue != nil) {
|
||||
GSWResponse_appendContentHTMLString(response, [self _filterSoftReturnsFromString:valueValue]);
|
||||
}
|
||||
id value = [_value valueInComponent:GSWContext_component(context)];
|
||||
if (value != nil)
|
||||
GSWResponse_appendContentHTMLString(response, [self _filterSoftReturnsFromString:NSStringWithObject(value)]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,39 +41,30 @@ RCS_ID("$Id$")
|
|||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
self = [super initWithName:@"input" associations:associations template: template];
|
||||
if (!self) {
|
||||
return nil;
|
||||
}
|
||||
if ((self = [super initWithName:@"input"
|
||||
associations:associations
|
||||
template: template]))
|
||||
{
|
||||
if (_value == nil
|
||||
|| ![_value isValueSettable])
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: 'value' attribute not present or is a constant",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
GSWAssignAndRemoveAssociation(&_formatter,_associations,formatter__Key);
|
||||
GSWAssignAndRemoveAssociation(&_dateFormat,_associations,dateFormat__Key);
|
||||
GSWAssignAndRemoveAssociation(&_numberFormat,_associations,numberFormat__Key);
|
||||
GSWAssignAndRemoveAssociation(&_useDecimalNumber,_associations,useDecimalNumber__Key);
|
||||
|
||||
if ((_value == nil) || (![_value isValueSettable])) {
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: 'value' attribute not present or is a constant",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
ASSIGN(_formatter, [_associations objectForKey: formatter__Key]);
|
||||
if (_formatter != nil) {
|
||||
[_associations removeObjectForKey: formatter__Key];
|
||||
}
|
||||
ASSIGN(_dateFormat, [_associations objectForKey: dateFormat__Key]);
|
||||
if (_dateFormat != nil) {
|
||||
[_associations removeObjectForKey: dateFormat__Key];
|
||||
}
|
||||
ASSIGN(_numberFormat, [_associations objectForKey: numberFormat__Key]);
|
||||
if (_numberFormat != nil) {
|
||||
[_associations removeObjectForKey: numberFormat__Key];
|
||||
}
|
||||
ASSIGN(_useDecimalNumber, [_associations objectForKey: useDecimalNumber__Key]);
|
||||
if (_useDecimalNumber != nil) {
|
||||
[_associations removeObjectForKey: useDecimalNumber__Key];
|
||||
}
|
||||
|
||||
if ((_dateFormat != nil) && (_numberFormat != nil)) {
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Cannot have 'dateFormat' and 'numberFormat' attributes at the same time.",
|
||||
__PRETTY_FUNCTION__];
|
||||
|
||||
}
|
||||
if (_dateFormat != nil
|
||||
&& _numberFormat != nil)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"%s: Cannot have 'dateFormat' and 'numberFormat' attributes at the same time.",
|
||||
__PRETTY_FUNCTION__];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -93,8 +84,8 @@ RCS_ID("$Id$")
|
|||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// TODO: put that into a superclass, bulid a cache?
|
||||
|
||||
-(NSFormatter*)formatterForComponent:(GSWComponent*)component
|
||||
{
|
||||
//OK
|
||||
|
@ -136,26 +127,35 @@ RCS_ID("$Id$")
|
|||
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
|
||||
if ((![self disabledInComponent: component]) && ([context _wasFormSubmitted])) {
|
||||
NSString * nameCtx = [self nameInContext:context];
|
||||
if (nameCtx != nil) {
|
||||
NSString* value = [request stringFormValueForKey: nameCtx];
|
||||
if (value != nil) {
|
||||
NSFormatter * formatter = nil;
|
||||
if ([value length] > 0) {
|
||||
formatter = [self formatterForComponent:component];
|
||||
}
|
||||
if (formatter != nil) {
|
||||
if (![self disabledInComponent: component]
|
||||
&& [context _wasFormSubmitted])
|
||||
{
|
||||
NSString * nameCtx = [self nameInContext:context];
|
||||
if (nameCtx != nil)
|
||||
{
|
||||
NSString* value = [request stringFormValueForKey: nameCtx];
|
||||
if (value != nil)
|
||||
{
|
||||
NSFormatter * formatter = nil;
|
||||
if ([value length] > 0)
|
||||
formatter = [self formatterForComponent:component];
|
||||
|
||||
if (formatter != nil)
|
||||
{
|
||||
if ([formatter getObjectValue:&resultValue
|
||||
forString:value
|
||||
errorDescription:&errorDscr]) {
|
||||
if (value && !resultValue) {
|
||||
NSWarnLog(@"There's a value (%@ of class %@) but no formattedValue with formater %@",
|
||||
forString:value
|
||||
errorDescription:&errorDscr])
|
||||
{
|
||||
if (!resultValue)
|
||||
{
|
||||
NSWarnLog(@"There's a value (%@ of class %@) but no formattedValue with formater %@",
|
||||
value,
|
||||
[value class],
|
||||
formatter);
|
||||
};
|
||||
} else {
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
NSException* exception=nil;
|
||||
NSString* valueKeyPath=[_value keyPath];
|
||||
|
||||
|
@ -171,52 +171,60 @@ RCS_ID("$Id$")
|
|||
keyPath:valueKeyPath];
|
||||
}
|
||||
|
||||
if ((value != nil) && (_useDecimalNumber != nil) && ([_useDecimalNumber boolValueInComponent:component])) {
|
||||
// not tested! maybe we need a stringValue here first? dw
|
||||
resultValue = [NSDecimalNumber decimalNumberWithString: value];
|
||||
}
|
||||
} else { // no formatter
|
||||
resultValue=value;
|
||||
if ([resultValue length] == 0) {
|
||||
resultValue = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
[_value setValue:resultValue
|
||||
inComponent:component];
|
||||
if (value != nil
|
||||
&& _useDecimalNumber != nil
|
||||
&& [_useDecimalNumber boolValueInComponent:component])
|
||||
{
|
||||
// not tested! maybe we need a stringValue here first? dw
|
||||
resultValue = [NSDecimalNumber decimalNumberWithString: value];
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // no formatter
|
||||
resultValue=value;
|
||||
if ([resultValue length] == 0)
|
||||
resultValue = nil;
|
||||
}
|
||||
}
|
||||
[_value setValue:resultValue
|
||||
inComponent:component];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendValueAttributeToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
GSWComponent * component = GSWContext_component(context);
|
||||
id value = [_value valueInComponent:component];
|
||||
NSFormatter* formatter = nil;
|
||||
id formattedValue=nil;
|
||||
|
||||
if (value != nil) {
|
||||
|
||||
formatter = [self formatterForComponent:component];
|
||||
if (formatter != nil) {
|
||||
NS_DURING
|
||||
formattedValue=[formatter stringForObjectValue:value];
|
||||
NS_HANDLER
|
||||
formattedValue = nil;
|
||||
NSLog(@"%s: value '%@' cannot be formatted.",
|
||||
__PRETTY_FUNCTION__, value);
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
if (formattedValue == nil)
|
||||
if (value != nil)
|
||||
{
|
||||
formattedValue = value;
|
||||
}
|
||||
NSFormatter* formatter = [self formatterForComponent:component];
|
||||
id formattedValue=nil;
|
||||
if (formatter != nil)
|
||||
{
|
||||
NS_DURING
|
||||
{
|
||||
formattedValue=[formatter stringForObjectValue:value];
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
formattedValue = nil;
|
||||
NSLog(@"%s: value '%@' cannot be formatted.",
|
||||
__PRETTY_FUNCTION__, value);
|
||||
}
|
||||
NS_ENDHANDLER;
|
||||
}
|
||||
if (formattedValue == nil)
|
||||
formattedValue = NSStringWithObject(value);
|
||||
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, value__Key, formattedValue, YES);
|
||||
}
|
||||
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, value__Key, formattedValue, YES);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void) _appendCloseTagToResponse:(GSWResponse *) response
|
||||
inContext:(GSWContext*) context
|
||||
{
|
||||
|
|
|
@ -42,13 +42,13 @@
|
|||
BOOL _temporaryKey;
|
||||
};
|
||||
|
||||
+ (void) _appendDataURLToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
key:(GSWAssociation*) key
|
||||
data:(GSWAssociation*) data
|
||||
mimeType:(GSWAssociation*) mimeType
|
||||
urlAttributeName:(NSString *) urlAttribute // @"src"
|
||||
inComponent:(GSWComponent*) component;
|
||||
+ (void) _appendDataURLAttributeToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
key:(GSWAssociation*) key
|
||||
data:(GSWAssociation*) data
|
||||
mimeType:(GSWAssociation*) mimeType
|
||||
urlAttributeName:(NSString *) urlAttribute // @"src"
|
||||
inComponent:(GSWComponent*) component;
|
||||
|
||||
-(id)initWithData:(NSData*)data
|
||||
mimeType:(NSString*)type
|
||||
|
|
|
@ -137,13 +137,13 @@ static Class NSStringClass = Nil;
|
|||
|
||||
|
||||
// _appendDataURLAttributeToResponse
|
||||
+ (void) _appendDataURLToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
key:(GSWAssociation*) key
|
||||
data:(GSWAssociation*) data
|
||||
mimeType:(GSWAssociation*) mimeType
|
||||
urlAttributeName:(NSString *) urlAttribute // @"src"
|
||||
inComponent:(GSWComponent*) component
|
||||
+ (void) _appendDataURLAttributeToResponse:(GSWResponse*) response
|
||||
inContext:(GSWContext*) context
|
||||
key:(GSWAssociation*) key
|
||||
data:(GSWAssociation*) data
|
||||
mimeType:(GSWAssociation*) mimeType
|
||||
urlAttributeName:(NSString *) urlAttribute // @"src"
|
||||
inComponent:(GSWComponent*) component
|
||||
{
|
||||
NSString * dataURL = [self _dataURLInContext: context
|
||||
key: key
|
||||
|
|
|
@ -135,6 +135,12 @@ GSWEB_EXPORT BOOL SBIsEqual(id id1,id id2);
|
|||
GSWEB_EXPORT BOOL SBIsValueEqual(id id1,id id2);
|
||||
GSWEB_EXPORT BOOL SBIsValueIsIn(id id1,id id2);
|
||||
|
||||
//returns YES if v is a NSNumber class and evaluate to YES
|
||||
GSWEB_EXPORT BOOL GSWIsBoolNumberYes(id v);
|
||||
|
||||
//returns YES if v is a NSNumber class and evaluate to NO
|
||||
GSWEB_EXPORT BOOL GSWIsBoolNumberNo(id v);
|
||||
|
||||
GSWEB_EXPORT NSTimeInterval NSTimeIntervalFromTimeVal(struct timeval* tv);
|
||||
GSWEB_EXPORT void NSTimeIntervalSleep(NSTimeInterval ti);
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
@ -68,6 +69,9 @@ static Class nsStringClass=Nil;
|
|||
static Class nsMutableStringClass=Nil;
|
||||
static Class eoNullClass=Nil;
|
||||
|
||||
SEL gswAppendStringSEL = NULL;
|
||||
SEL gswObjectAtIndexSEL = NULL;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
void GSWInitializeAllMisc()
|
||||
{
|
||||
|
@ -76,6 +80,9 @@ void GSWInitializeAllMisc()
|
|||
{
|
||||
initialized=YES;
|
||||
|
||||
gswAppendStringSEL = @selector(appendString:);
|
||||
gswObjectAtIndexSEL = @selector(objectAtIndex:);
|
||||
|
||||
// Yes & No
|
||||
ASSIGN(cachedGSWNumber_Yes,([NSNumber numberWithBool:YES]));
|
||||
ASSIGN(cachedGSWNumber_No,([NSNumber numberWithBool:NO]));
|
||||
|
@ -390,14 +397,33 @@ BOOL SBIsValueIsIn(id id1,id id2)
|
|||
{
|
||||
int i=0;
|
||||
int count=[id2 count];
|
||||
IMP oaiIMP=NULL;
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
if (SBIsValueEqual(id1,[id2 objectAtIndex:i]))
|
||||
if (SBIsValueEqual(id1,GSWeb_objectAtIndexWithImpPtr(id2,&oaiIMP,i)))
|
||||
return YES;
|
||||
};
|
||||
return NO;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
//returns YES if v is a NSNumber class and evaluate to YES
|
||||
BOOL GSWIsBoolNumberYes(id v)
|
||||
{
|
||||
return (([v isKindOfClass:[NSNumber class]]
|
||||
&& [v boolValue] == YES) ? YES : NO);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
//returns YES if v is a NSNumber class and evaluate to NO
|
||||
BOOL GSWIsBoolNumberNo(id v)
|
||||
{
|
||||
return (([v isKindOfClass:[NSNumber class]]
|
||||
&& [v boolValue] == NO) ? YES : NO);
|
||||
|
||||
}
|
||||
|
||||
/* The number of seconds between 1/1/2001 and 1/1/1970 = -978307200. */
|
||||
/* This number comes from:
|
||||
-(((31 years * 365 days) + 8 days for leap years) =total number of days
|
||||
|
@ -771,12 +797,13 @@ void ExceptionRaiseFn0(const char *func,
|
|||
//TODO better method
|
||||
int i=0;
|
||||
int count=[_array count];
|
||||
IMP oaiIMP=NULL;
|
||||
NSComparisonResult result=NSOrderedSame;
|
||||
|
||||
for(i=0;result!=NSOrderedDescending && i<count;i++)
|
||||
{
|
||||
result=(NSComparisonResult)[object performSelector:_compareSelector
|
||||
withObject:[_array objectAtIndex:i]];
|
||||
withObject:GSWeb_objectAtIndexWithImpPtr(_array,&oaiIMP,i)];
|
||||
|
||||
if (result==NSOrderedDescending)
|
||||
[_array insertObject:object
|
||||
|
@ -792,10 +819,11 @@ void ExceptionRaiseFn0(const char *func,
|
|||
{
|
||||
int i;
|
||||
int count=[array count];
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
[_array addObject:[array objectAtIndex:i]];
|
||||
[_array addObject:GSWeb_objectAtIndexWithImpPtr(array,&oaiIMP,i)];
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1059,18 +1087,23 @@ loggedUnlockFromFunctionInFileInLine(id self,
|
|||
withObject:(id)object2
|
||||
{
|
||||
NSUInteger i = [self count];
|
||||
IMP oaiIMP=NULL;
|
||||
while (i-- > 0)
|
||||
[[self objectAtIndex:i]performSelector:selector
|
||||
withObject:object1
|
||||
withObject:object2];
|
||||
{
|
||||
[GSWeb_objectAtIndexWithImpPtr(self,&oaiIMP,i)
|
||||
performSelector:selector
|
||||
withObject:object1
|
||||
withObject:object2];
|
||||
}
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(void)makeObjectsPerformSelectorIfPossible:(SEL)aSelector
|
||||
{
|
||||
NSUInteger i = [self count];
|
||||
IMP oaiIMP=NULL;
|
||||
while (i-->0)
|
||||
[[self objectAtIndex: i] performSelectorIfPossible:aSelector];
|
||||
[GSWeb_objectAtIndexWithImpPtr(self,&oaiIMP,i) performSelectorIfPossible:aSelector];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -1084,9 +1117,13 @@ loggedUnlockFromFunctionInFileInLine(id self,
|
|||
withObject:(id)argument
|
||||
{
|
||||
NSUInteger i = [self count];
|
||||
IMP oaiIMP=NULL;
|
||||
while (i-->0)
|
||||
[[self objectAtIndex: i] performSelectorIfPossible:aSelector
|
||||
withObject:argument];
|
||||
{
|
||||
[GSWeb_objectAtIndexWithImpPtr(self,&oaiIMP,i)
|
||||
performSelectorIfPossible:aSelector
|
||||
withObject:argument];
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -1095,10 +1132,14 @@ loggedUnlockFromFunctionInFileInLine(id self,
|
|||
withObject:(id)argument2
|
||||
{
|
||||
NSUInteger i = [self count];
|
||||
IMP oaiIMP=NULL;
|
||||
while (i-->0)
|
||||
[[self objectAtIndex: i] performSelectorIfPossible:aSelector
|
||||
withObject:argument1
|
||||
withObject:argument2];
|
||||
{
|
||||
[GSWeb_objectAtIndexWithImpPtr(self,&oaiIMP,i)
|
||||
performSelectorIfPossible:aSelector
|
||||
withObject:argument1
|
||||
withObject:argument2];
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -1109,7 +1150,6 @@ loggedUnlockFromFunctionInFileInLine(id self,
|
|||
withObject: argument];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
//====================================================================
|
||||
|
@ -1361,10 +1401,11 @@ NSString* GSWGetDefaultDocRoot()
|
|||
int i=0;
|
||||
id object=nil;
|
||||
id key=nil;
|
||||
IMP oaiIMP=NULL;
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
//TODO optimiser
|
||||
object=[array objectAtIndex:i];
|
||||
object=GSWeb_objectAtIndexWithImpPtr(array,&oaiIMP,i);
|
||||
key=[object performSelector:sel];
|
||||
NSAssert1(key,@"NSDictionary dictionaryWithArray: no key for object:%@",object);
|
||||
[dict setObject:object
|
||||
|
@ -1383,10 +1424,11 @@ NSString* GSWGetDefaultDocRoot()
|
|||
int i=0;
|
||||
id object=nil;
|
||||
id key=nil;
|
||||
IMP oaiIMP=NULL;
|
||||
for(i=0;i<count;i++)
|
||||
{
|
||||
//TODO optimiser
|
||||
object=[array objectAtIndex:i];
|
||||
object=GSWeb_objectAtIndexWithImpPtr(array,&oaiIMP,i);
|
||||
key=[object performSelector:sel
|
||||
withObject:anObject];
|
||||
NSAssert1(key,@"NSDictionary dictionaryWithArray: no key for object:%@",object);
|
||||
|
@ -1818,9 +1860,10 @@ NSString* GSWGetDefaultDocRoot()
|
|||
{
|
||||
NSUInteger selfLength=[self length];
|
||||
NSUInteger searchedLength=[data length];
|
||||
if (aRange.location+aRange.length>selfLength)
|
||||
if (aRange.location+aRange.length>selfLength
|
||||
|| searchedLength>selfLength)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (selfLength>0 && searchedLength>0)
|
||||
{
|
||||
const unsigned char* bytes=(const unsigned char*)[self bytes];
|
||||
|
@ -1850,8 +1893,8 @@ NSString* GSWGetDefaultDocRoot()
|
|||
|
||||
//--------------------------------------------------------------------
|
||||
- (NSUInteger) replaceOccurrencesOfData: (NSData*)replace
|
||||
withData: (NSData*)by
|
||||
range: (NSRange)searchRange
|
||||
withData: (NSData*)by
|
||||
range: (NSRange)searchRange
|
||||
{
|
||||
NSRange range;
|
||||
NSUInteger count = 0;
|
||||
|
@ -1935,11 +1978,7 @@ NSString* NSStringWithObject(id object)
|
|||
NSCAssert(nsMutableStringClass,@"GSWUtils not initialized");
|
||||
if (object)
|
||||
{
|
||||
if ([object isKindOfClass:nsMutableStringClass])
|
||||
// why wasting memory? -- dw
|
||||
// string=AUTORELEASE([object copy]);
|
||||
string=(NSString*)object;
|
||||
else if ([object isKindOfClass:nsStringClass])
|
||||
if ([object isKindOfClass:nsStringClass])
|
||||
string=(NSString*)object;
|
||||
else if ([object isKindOfClass:eoNullClass])
|
||||
string=@"";
|
||||
|
|
|
@ -36,27 +36,18 @@ RCS_ID("$Id$")
|
|||
//====================================================================
|
||||
@implementation GSWVBScript
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
-(id)initWithName:(NSString*)aName
|
||||
associations:(NSDictionary*)associations
|
||||
template:(GSWElement*)templateElement
|
||||
template:(GSWElement*)template
|
||||
{
|
||||
GSWAssociation* languageAssociation=nil;
|
||||
NSMutableDictionary* tmpAssociations=[NSMutableDictionary dictionaryWithDictionary:associations];
|
||||
|
||||
if (![tmpAssociations objectForKey:language__Key])
|
||||
{
|
||||
// Create and set the language (Javascript)
|
||||
languageAssociation=[GSWConstantValueAssociation associationWithValue:@"VBScript"]; //???
|
||||
[tmpAssociations setObject:languageAssociation
|
||||
forKey:language__Key];
|
||||
};
|
||||
if ((self=[super initWithName:aName
|
||||
associations:tmpAssociations
|
||||
template:templateElement]))
|
||||
associations:associations
|
||||
template:template]))
|
||||
{
|
||||
[self setLanguage:@"VBScript"];
|
||||
};
|
||||
return self;
|
||||
};
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
@end
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
|
||||
#ifndef GNUSTEP
|
||||
#include <GNUstepBase/GSObjCRuntime.h>
|
||||
|
@ -687,12 +688,13 @@ NSString* baseStringByConvertingFromHTML(NSString* string,GSWHTMLConvertingStruc
|
|||
NSArray* listItems = [self componentsSeparatedByString:sep1];
|
||||
NSUInteger iCount=0;
|
||||
NSUInteger itemsCount=[listItems count];
|
||||
IMP oaiIMP=NULL;
|
||||
|
||||
pDico=(NSMutableDictionary*)[NSMutableDictionary dictionary];
|
||||
|
||||
for(iCount=0;iCount<itemsCount;iCount++)
|
||||
{
|
||||
if ([[listItems objectAtIndex:iCount] length]>0)
|
||||
if ([GSWeb_objectAtIndexWithImpPtr(listItems,&oaiIMP,iCount) length]>0)
|
||||
{
|
||||
NSArray* listParam = [[listItems objectAtIndex:iCount] componentsSeparatedByString:sep2];
|
||||
id key=nil;
|
||||
|
|
|
@ -90,4 +90,6 @@
|
|||
-(void)removeQuote:(NSString*)quote;
|
||||
@end
|
||||
|
||||
GSWEB_EXPORT NSString* GSWJoinedStrings(int stringsCount,NSString* s1,...);
|
||||
|
||||
#endif //_NSString_Trimming_h__
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
RCS_ID("$Id$")
|
||||
|
||||
#include "GSWeb.h"
|
||||
#include "GSWPrivate.h"
|
||||
#include <time.h>
|
||||
|
||||
//====================================================================
|
||||
|
@ -276,3 +277,36 @@ RCS_ID("$Id$")
|
|||
};
|
||||
@end
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
NSString* GSWJoinedStrings(int stringsCount,NSString* s1,...)
|
||||
{
|
||||
NSString* result=nil;
|
||||
if (stringsCount>0)
|
||||
{
|
||||
NSMutableString* tmp=nil;
|
||||
//GSODFLog(@"s1=%@",result);
|
||||
if (stringsCount==1)
|
||||
tmp=(NSMutableString*)s1;
|
||||
else
|
||||
{
|
||||
IMP asIMP=NULL;
|
||||
va_list ap;
|
||||
va_start(ap,s1);
|
||||
int i=0;
|
||||
for(i=0;i<stringsCount;i++)
|
||||
{
|
||||
NSString* s=(i==0 ? s1 : va_arg(ap,NSString*));
|
||||
if (s)
|
||||
{
|
||||
if (!tmp)
|
||||
tmp=[NSMutableString string];
|
||||
GSWeb_appendStringWithImpPtr(tmp,&asIMP,s);
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
}
|
||||
if (tmp!=nil)
|
||||
result=[NSString stringWithString:tmp];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue