libs-gsweb/GSWeb.framework/GSWInput.m
Manuel Guesdon 2283c65a13 2003-01-22 Manuel Guesdon <mguesdon@orange-concept.com>
* GSWeb.framework/Makefile.postamble:
		o use $(LN_S) -f in install-WO-headers
		o added $(MKDIRS) $(GNUSTEP_HEADERS)/$(GSWExtensions_wo_HEADER_FILES_INSTALL_DIR);
	* GSWExtensionsGSW.framework/Makefile.postamble: use $(LN_S) -f in install-WO-headers

2003-01-20   David Ayers <d.ayers@inode.at>
	* Makefile.postamble
		o added support for make gswnames=(gsw,wo,all) (corrected
		typo)
		o reinserted support for $(INSTALL_ROOT_DIR)
	* config.h.in
		o added HAVE_GDL2
	* configure
		o added support for --with-gswnames=(gsw,wo,all)
		o set LIBWRAP during configure
		o added config.mak.in as configurable file
	* configure.ac
		o (see configure)
	* config.mak: removed (replaced by config.mak.in)
	* config.mak.in: new file
		o added support for make gswnames=(gsw,wo,all)
	* gsweb.make.in
		o add GSANTLR as auxiliary lib
		o add gsweb libs to AUXILIARY_GSW_LIBS
		o include correct extensions for GSW/WO-libs
	* gsweb_wo.make: new file
	* GSWeb/GSWConfig.h
		o changed support for GSWEB_WONAMES
		o conditionally import file GSWWOCompatiblity
		  here instead of in GSWeb.h
	* GSWeb/GNUMakefile
		o added support for make gswnames=(gsw,wo,all)
		o ensure each lib gets built with its own object files
		o removed deactivated framework extension determination code
		o removed reference to unused files:
		  GSWeb.m, GSWWOCompatibility.m
		o added references to new files:
		  GSWExtenstions.h, GSWExtWOCompatibility.h
		o added support to create WO header files
	* GSWeb/Makefile.postamble
		o changed support to install WO header files according to
	          make gswnames=(gsw,wo,all)
		o remove Makefile.preamble during distclean
	* GSWeb/Makefile.preamble.in
		o fixed typo
	* GSWeb/GSWeb.h
		o moved GSW/WO-Name-mapping to GSWWOCompatibility.h
		o replaced inclusions of
		  <GSWeb/file.h> with "file.h"
	* GSWeb/GSWeb.m: removed
	* GSWeb/GSWWOCompatibility.h
		o changed GSWEB_WONAMES handling
		o removed hybrid namespace WO subclasses
		o moved & reorganized GSW/WO-Name-mapping from GSWeb.h
		o inlucluded missing GSW/WO-Name-mappings
	* GSWeb/GSWWOCompatibility.m: removed
	* GSWeb/*.m
		o replaced inclusions of
		  <GSWeb/file.h> with "file.h"
	* GSWeb/GSWApplication.m
		o remove special GSW/WO handling of WOApp
	* GSWeb/WebObject/WO*: removed
	* GSWeb/WebObject/WebObjects
		o replaced inclusions of
		  <GSWeb/file.h> with "file.h"
	* GSWExtensions/GNUMakefile
		o added support for make gswnames=(gsw,wo,all)
		o ensure each lib gets built with its own object files
		o removed deactivated framework extension determination code
		o added references to new files:
		  GSWExtenstions.h, GSWExtWOCompatibility.h
		o added support to create WO header files
	* GSWExtensions/Makefile.preamble
		o let gnustep make figure whether to link agains debug libs
		o added support for make gswnames=(gsw,wo,all)
	* GSWExtensions/Makefile.postamble
		o changed support to install WO header files according to
	          make gswnames=(gsw,wo,all)
	* GSWExtensions/*.m
		o replaced inclusions of
		  <GSWeb/GSWeb.h> with "GSWExtWOCompatibility.h"
		o replaces inclusions of
		  <GSWExtensions/file.h> with "file.h"
	* GSWExtensions/GSWExtensions.h: new file
	* GSWExtensions/WOExtensions.h: new file
	* GSWExtensions/GSWExtWOCompatibility.h: new file
	* GSWExtensionsGSW/GNUMakefile
		o added support for make gswnames=(gsw,wo,all)
		o ensure each lib gets built with its own object files
		o removed deactivated framework extension determination code
		o added references to new file GSWExtGSWWOCompatibility.h
		o added support to create WO header files
	* GSWExtensionsGSW/Makefile.pramble
		o let gnustep make figure whether to link agains debug libs
		o added support for make gswnames=(gsw,wo,all)
	        o removed GSWExtensions from ADDITIONAL_LIB_DIRS
	* GSWExtensionsGSW/*.m
		o replaced inclusions of
		  <GSWeb/GSWeb.h> with "GSWExtGSWWOCompatibility.h"
	* GSWExtensions/GSWExtGSWWOCompatibility.h: new file


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@15675 72102866-910b-0410-8b05-ffd578937521
2003-01-22 12:24:26 +00:00

365 lines
12 KiB
Objective-C

/** GSWInput.m - <title>GSWeb: Class GSWInput</title>
Copyright (C) 1999-2002 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Feb 1999
$Revision$
$Date$
$Id$
This file is part of the GNUstep Web Library.
<license>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</license>
**/
#include "GSWeb.h"
//====================================================================
@implementation GSWInput
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)aName
associations:(NSDictionary*)associations
contentElements:(NSArray*)elements
{
NSMutableDictionary* attributedAssociations=[[associations mutableCopy] autorelease];
LOGObjectFnStartC("GSWInput");
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ elements=%@",aName,associations,elements);
[attributedAssociations removeObjectForKey:disabled__Key];
[attributedAssociations removeObjectForKey:enabled__Key];
[attributedAssociations removeObjectForKey:value__Key];
[attributedAssociations removeObjectForKey:name__Key];
if (!WOStrictFlag)
[attributedAssociations removeObjectForKey:handleValidationException__Key];
_value = [[associations objectForKey:value__Key
withDefaultObject:[_value autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWInput: value=%@",_value);
if ((self=[super initWithName:aName
attributeAssociations:attributedAssociations
contentElements:elements]))
{
_disabled = [[associations objectForKey:disabled__Key
withDefaultObject:[_disabled autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWInput: disabled=%@",_disabled);
if (!WOStrictFlag)
{
_enabled = [[associations objectForKey:enabled__Key
withDefaultObject:[_enabled autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWInput: enabled=%@",_enabled);
if (_disabled && _enabled)
{
ExceptionRaise0(@"GSWInput",@"You can't use 'diabled' and 'enabled' parameters at the same time.");
};
};
_name = [[associations objectForKey:name__Key
withDefaultObject:[_name autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWInput: name=%@",_name);
if (!WOStrictFlag)
{
_handleValidationException = [[associations objectForKey:handleValidationException__Key
withDefaultObject:[_handleValidationException autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWInput: handleValidationException=%@",_handleValidationException);
// Turbocat Additions
// [attributedAssociations removeObjectForKey: escapeHTML__Key];
if ([associations objectForKey: escapeHTML__Key])
{
_tcEscapeHTML = [[associations objectForKey:escapeHTML__Key
withDefaultObject:nil] retain];
};
};
};
LOGObjectFnStopC("GSWInput");
return self;
};
//--------------------------------------------------------------------
-(void)dealloc
{
DESTROY(_disabled);
DESTROY(_enabled);//GSWeb Only
DESTROY(_name);
DESTROY(_value);
DESTROY(_handleValidationException);//GSWeb Only
DESTROY(_tcEscapeHTML);//GSWeb Only
[super dealloc];
};
//--------------------------------------------------------------------
-(NSString*)elementName
{
return @"INPUT";
};
@end
//==============================================================================
@implementation GSWInput (GSWInputA)
//--------------------------------------------------------------------
-(NSString*)nameInContext:(GSWContext*)context
{
//OK
GSWComponent* component=nil;
NSString* nameValue=nil;
LOGObjectFnStartC("GSWInput");
GSWAssertIsElementID(context);
if (_name)
{
component=[context component];
nameValue=[_name valueInComponent:component];
}
else
{
nameValue=[context elementID];
NSDebugMLLog(@"gswdync",@"elementID=%@",[context elementID]);
};
NSDebugMLLog(@"gswdync",@"nameValue=%@",nameValue);
GSWAssertIsElementID(context);
LOGObjectFnStopC("GSWInput");
return nameValue;
};
//--------------------------------------------------------------------
/** return the value used in appendValueToResponse:inContext: **/
-(id)valueInContext:(GSWContext*)context
{
id value=nil;
LOGObjectFnStartC("GSWInput");
if (_value)
{
GSWComponent* component=nil;
component=[context component];
value=[_value valueInComponent:component];
NSDebugMLLog(@"gswdync",@"value=%@",value);
};
LOGObjectFnStopC("GSWInput");
return value;
};
//--------------------------------------------------------------------
-(BOOL)disabledInContext:(GSWContext*)context
{
if (!WOStrictFlag && _enabled)
return ![self evaluateCondition:_enabled
inContext:context];
else
return [self evaluateCondition:_disabled
inContext:context];
};
@end
//==============================================================================
@implementation GSWInput (GSWInputB)
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request
inContext:(GSWContext*)context
{
//OK
BOOL disabledInContext=NO;
LOGObjectFnStartC("GSWInput");
GSWStartElement(context);
GSWAssertCorrectElementID(context);
disabledInContext=[self disabledInContext:context]; //return 0
if (!disabledInContext)
{
BOOL wasFormSubmitted=[context _wasFormSubmitted];
if (wasFormSubmitted)
{
GSWComponent* component=[context component];
NSString* nameInContext=[self nameInContext:context];
NSString* valueValue=[request formValueForKey:nameInContext];
NSDebugMLLog(@"gswdync",@"nameInContext=%@",nameInContext);
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
NS_DURING
{
[_value setValue:valueValue
inComponent:component];
};
NS_HANDLER
{
LOGException(@"GSWInput _value=%@ valueValue=%@ exception=%@",
_value,valueValue,localException);
if (!WOStrictFlag)
{
[self handleValidationException:localException
inContext:context];
}
else
{
[localException raise];
};
}
NS_ENDHANDLER;
};
};
GSWAssertIsElementID(context);
LOGObjectFnStopC("GSWInput");
};
@end
//====================================================================
@implementation GSWInput (GSWInputC)
//--------------------------------------------------------------------
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
//OK
BOOL disabledInContext=NO;
LOGObjectFnStartC("GSWInput");
disabledInContext=[self disabledInContext:context]; //return 0
if (disabledInContext)
[response _appendContentAsciiString:@" disabled"];
[self appendNameToResponse:response
inContext:context];
[self appendValueToResponse:response
inContext:context];
LOGObjectFnStopC("GSWInput");
};
//--------------------------------------------------------------------
-(void)appendValueToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
//OK
id valueValue=nil;
LOGObjectFnStartC("GSWInput");
valueValue=[self valueInContext:(GSWContext*)context];
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
if (valueValue)
{
[response appendContentCharacter:' '];
[response _appendContentAsciiString:@"value"];
[response appendContentCharacter:'='];
[response appendContentCharacter:'"'];
if (_tcEscapeHTML && [self evaluateCondition:_tcEscapeHTML
inContext:context] == NO)
{
[response appendContentString:valueValue];
}
else
{
[response appendContentHTMLAttributeValue:valueValue];
};
[response appendContentCharacter:'"'];
};
LOGObjectFnStopC("GSWInput");
};
//--------------------------------------------------------------------
-(void)appendNameToResponse:(GSWResponse*)response
inContext:(GSWContext*)context
{
//OK
NSString* name=nil;
LOGObjectFnStartC("GSWInput");
name=[self nameInContext:context];
NSDebugMLLog(@"gswdync",@"name=%@",name);
if (name)
{
[response appendContentCharacter:' '];
[response _appendContentAsciiString:@"name"];
[response appendContentCharacter:'='];
[response appendContentCharacter:'"'];
[response appendContentHTMLAttributeValue:name];
[response appendContentCharacter:'"'];
};
LOGObjectFnStopC("GSWInput");
};
@end
//====================================================================
@implementation GSWInput (GSWInputD)
//--------------------------------------------------------------------
+(BOOL)hasGSWebObjectsAssociations
{
return YES;
};
@end
//====================================================================
@implementation GSWInput (GSWInputE)
//GSWeb additions {
-(void)handleValidationException:(NSException*)exception
inContext:(GSWContext*)context
{
BOOL isValidationException=[exception isValidationException];
BOOL raise=YES;
LOGObjectFnStartC("GSWInput");
if (isValidationException)
{
GSWComponent* component=[context component];
id handleValidationException=[handleValidationException valueInComponent:component];
BOOL handle=NO;
if (!handleValidationException)
{
handleValidationException = [component handleValidationExceptionDefault];
};
if (handleValidationException)
{
if ([handleValidationException isEqualToString:@"handleAndRaise"])
{
handle=YES;
raise=YES;
}
else if ([handleValidationException isEqualToString:@"handle"])
{
handle=YES;
raise=NO;
}
else if ([handleValidationException isEqualToString:@"raise"])
{
handle=NO;
raise=YES;
}
else
{
NSDebugMLog(@"Unknown case for handleValidationException %@",handleValidationException);
};
};
if (handle)
{
NSDebugMLog(@"Handled validation exception %@",exception);
[component setValidationFailureMessage:[[exception userInfo]objectForKey:@"message"]
forElement:self];
}
else
{
NSDebugMLog(@"Unhandled validation exception %@",exception);
};
};
if (raise)
{
NSDebugMLog(@"Raise exception %@",exception);
exception=ExceptionByAddingUserInfoObjectFrameInfo0(exception,@"handleValidationException:inContext");
[exception raise];
};
LOGObjectFnStopC("GSWInput");
};
// }
@end