mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-02-22 11:11:21 +00:00
* GSWeb/GSWApplication.m o removed unused +initialize * GSWeb/GSWDefaultAdaptorThread.m: o more information on "bad request first line" exception * GSWeb/GSWHTMLDynamicElement.m o in -initWithName:attributeAssociations:contentElements: add "" to association values because XML parser romove them. o added -computeActionStringWithActionClassAssociation: directActionNameAssociation:inContext: o added -computeQueryDictionaryWithActionClassAssociation: directActionNameAssociation:queryDictionaryAssociation: otherQueryAssociations:inContext: * GSWeb/GSWResponse.m: o don't append debugcomment if !GSDebugSet(@"debugComments") o fixed bug in appendContentString: in NSAssert3 params o adedd -_appendTagAttribute:value:escapingHTMLAttributeValue: o added GSWResponse (GSWResponseRedirected) * GSWeb/GSWResponse.h: o added -forceFinalizeInContext o added GSWResponse (GSWResponseRedirected) * GSWeb/GSWTemplateParserXML.m: o only include comments if [GSWApplication includeCommentsInResponses] * GSWExtensions.framework/GSWLongResponsePage.m: o in -cancel call cancelPageForStatus: instead of cancelPage o declare private interface * GSWeb/GSWComponent.m: o don't output end of component commend if !DEBUG && !GSDebugSet(@"gswcomponents") o fixes in _generateResponseInContext: * GSWeb/GSWContext.[hm]: o added _userInfo to enable developper context specific temporary information storage o added -userInfo o added -_generateRelativeURLs o make -_generateCompleteURLs returning previous state. o added -directActionURLForActionNamed:queryDictionary:isSecure: o added -_directActionURLForActionNamed:queryDictionary:isSecure:url: o added -componentActionURLIsSecure: o modified -session o modified -_takeAwakeComponent: to not add already added component o implemented _takeAwakeComponentsFromArray; o fixed -_incrementContextID o added _session o fixes in -copyWithZone to keep mutable objects mutables. o added _requestContextID o added -_setRequestContextID: and -_requestContextID; * GSWeb/GSWHyperlink.[hm]: o added _secure o added binding validation tests o fixes in -appendToResponse:inContext: o handle correctly otherQueryAssociations (bindings starting with '?') * GSWeb/GSWConstants.[hm]: o added cidStore__Key for GSWHTMLURLValuedElement o added cidKey__Key for GSWHTMLURLValuedElement * GSWeb/GSWImage.[hm]: o added _width, _height * GSWeb/GSWHTMLURLValuedElement.[hm] o implemented -_appendCGIActionURLToResponse:inContext: o implemented -computeActionStringInContext: o implemented -computeQueryDictionaryInContext: o handle otherQueryAssociations (bindings starting with '?') o handle cidStore and cidKey * GSWeb/GSWRequest.[hm]: o added _context o changes for compilation warnings o added -sessionIDFromValuesOrCookieByLookingForCookieFirst: o added +_lookForIDsInCookiesFirst o rewrite form/uri/cookie values retrieving (for sessionID,...) o new use GSMimeParser for formData parsing * Doc/antlr.txt added * GSWeb/GSWPageDefParser.[hm] regenerated to handle (bindings starting with '?') * GSWeb/GSWPageDefParserTokenTypes.txt regenerated to handle (bindings starting with '?') * GSWeb/GSWPageDefParserTokenTypes.h regenerated to handle (bindings starting with '?') * GSWeb/GSWPageDefLexer.[hm] regenerated to handle (bindings starting with '?') * GSWeb/GSWUtils.[hm]: o added -extractObjectsForKeysWithPrefix:removePrefix: o fixed bug in HexStringToData o fixed bug in NSDictionary +dictionaryWithArray:onSelector:withObject: * GSWeb/GSWForm.[hm] o handle otherQueryAssociations (bindings starting with '?') o implemented -computeQueryDictionaryInContext: o implemented/fixed -_appendHiddenFieldsToResponse:inContext: o implemented -_appendCGIActionToResponse:inContext: o fix -appendGSWebObjectsAssociationsToResponse:inContext: for directAction o added -computeActionStringInContext: o fixed -invokeActionForRequest:inContext: to invoke action when to element is invoked * GSWeb/GSWDirectAction.m: o fixed -_initializeRequestSessionIDInContext: o added -sessionIDForRequest: * GSWeb/NSString+HTML.[hm]: o added -dictionaryWithSep1:withSep2:withOptionUnescape:forceArray: * GSWeb/NSString+Trimming.m: o fix in +stringUniqueIdWithLength: initialize random generator * GSWeb/GSWSession.[hm]: o added createSessionID which create better sessionID (uniq in time and larger to give better security) o fixes in _saveCurrentPage * GSWeb/GSWBundle.m: o fix compiler warning git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@15630 72102866-910b-0410-8b05-ffd578937521
870 lines
30 KiB
Objective-C
870 lines
30 KiB
Objective-C
/** GSWHTMLDynamicElement.m - <title>GSWeb: Class GSWHTMLDynamicElement</title>
|
|
|
|
Copyright (C) 1999-2003 Free Software Foundation, Inc.
|
|
|
|
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
|
|
Date: Feb 1999
|
|
|
|
$Revision$
|
|
$Date$
|
|
$Id$
|
|
|
|
<abstract></abstract>
|
|
|
|
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>
|
|
**/
|
|
|
|
static const char rcsId[]="$Id$";
|
|
|
|
#include <GSWeb/GSWeb.h>
|
|
|
|
//====================================================================
|
|
@implementation GSWHTMLDynamicElement
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
-(id)initWithName:(NSString*)elementName
|
|
associations:(NSDictionary*)associations
|
|
contentElements:(NSArray*)elements
|
|
{
|
|
LOGObjectFnStartC("GSWHTMLDynamicElement");
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
NSDebugMLLog(@"gswdync",@"elementName=%@ associations:%@ elements=%@",elementName,associations,elements);
|
|
if ((self=[super initWithName:elementName
|
|
associations:associations
|
|
template:nil]))
|
|
{
|
|
};
|
|
LOGObjectFnStopC("GSWHTMLDynamicElement");
|
|
return self;
|
|
};
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
-(id)initWithName:(NSString*)elementName
|
|
attributeAssociations:(NSDictionary*)attributeAssociations
|
|
contentElements:(NSArray*)elements
|
|
{
|
|
//OK
|
|
NSString* dynamicElementName=[[self elementName] uppercaseString];
|
|
LOGObjectFnStartC("GSWHTMLDynamicElement");
|
|
NSDebugMLLog(@"gswdync",@"elementName=%@ attributeAssociations_:%@ elements=%@ dynamicElementName=%@",
|
|
elementName,
|
|
attributeAssociations,
|
|
elements,
|
|
dynamicElementName);
|
|
if ((self=[super initWithName:dynamicElementName
|
|
associations:attributeAssociations
|
|
template:nil]))
|
|
{
|
|
NSMutableArray* attributeAssociationsValues=[NSMutableArray array];
|
|
NSEnumerator* attributesKeyEnum=nil;
|
|
id key=nil;
|
|
NSMutableArray* htmlBareStrings=[NSMutableArray array];
|
|
NSMutableData* elementsMap=[[NSMutableData new]autorelease];
|
|
BOOL hasGSWebObjectsAssociations=NO;
|
|
int GSWebObjectsAssociationsCount=0;
|
|
BOOL escapeHTML=[[self class] escapeHTML];// (return NO)
|
|
if (escapeHTML)
|
|
{
|
|
//TODO
|
|
};
|
|
|
|
//("<INPUT", " type", "=", text, ">")
|
|
if (dynamicElementName)
|
|
{
|
|
[htmlBareStrings addObject:[NSString stringWithFormat:@"<%@",
|
|
dynamicElementName]];
|
|
[elementsMap appendBytes:&ElementsMap_htmlBareString
|
|
length:1];
|
|
};
|
|
|
|
attributesKeyEnum= [attributeAssociations keyEnumerator];
|
|
NSDebugMLLog(@"gswdync",@"attributesKeyEnum=%@ attributeAssociations=%@",
|
|
attributesKeyEnum,attributeAssociations);
|
|
while ((key = [attributesKeyEnum nextObject]))
|
|
{
|
|
id association=[attributeAssociations objectForKey:key];
|
|
id associationValue=[association valueInComponent:nil];
|
|
NSDebugMLLog(@"gswdync",@"association=%@ associationValue=%@",
|
|
association,associationValue);
|
|
[htmlBareStrings addObject:[NSString stringWithFormat:@" %@",key]];
|
|
[elementsMap appendBytes:&ElementsMap_htmlBareString
|
|
length:1];
|
|
if (associationValue)
|
|
{
|
|
[htmlBareStrings addObject:[NSString stringWithString:@"="]];
|
|
[elementsMap appendBytes:&ElementsMap_htmlBareString
|
|
length:1];
|
|
associationValue=[NSString stringWithFormat:@"%@",associationValue];
|
|
// Parser remove "";
|
|
if ([associationValue hasPrefix:@"\""])
|
|
associationValue=[NSString stringWithFormat:@"\"%@\"",associationValue];
|
|
[htmlBareStrings addObject:associationValue];
|
|
[elementsMap appendBytes:&ElementsMap_htmlBareString
|
|
length:1];
|
|
}
|
|
else
|
|
{
|
|
//TODOV
|
|
[attributeAssociationsValues addObject:association];
|
|
[elementsMap appendBytes:&ElementsMap_attributeElement
|
|
length:1];
|
|
|
|
};
|
|
};
|
|
GSWebObjectsAssociationsCount=[self GSWebObjectsAssociationsCount];
|
|
if (GSWebObjectsAssociationsCount>0)
|
|
hasGSWebObjectsAssociations=YES;
|
|
else
|
|
hasGSWebObjectsAssociations=[[self class]hasGSWebObjectsAssociations]; //return:YES
|
|
if (hasGSWebObjectsAssociations)
|
|
{
|
|
[elementsMap appendBytes:&ElementsMap_gswebElement
|
|
length:1];
|
|
};
|
|
[htmlBareStrings addObject:@">"];
|
|
[elementsMap appendBytes:&ElementsMap_htmlBareString
|
|
length:1];
|
|
if (elements)
|
|
{
|
|
int elementsN=[elements count];
|
|
for(;elementsN>0;elementsN--)
|
|
[elementsMap appendBytes:&ElementsMap_dynamicElement
|
|
length:1];
|
|
if (dynamicElementName)
|
|
{
|
|
[htmlBareStrings addObject:[NSString stringWithFormat:@"</%@>",
|
|
dynamicElementName]];
|
|
[elementsMap appendBytes:&ElementsMap_htmlBareString
|
|
length:1];
|
|
};
|
|
};
|
|
[self _initWithElementsMap:elementsMap
|
|
htmlBareStrings:htmlBareStrings
|
|
dynamicChildren:elements
|
|
attributeAssociations:attributeAssociationsValues];
|
|
};
|
|
LOGObjectFnStopC("GSWHTMLDynamicElement");
|
|
return self;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(id)initWithName:(NSString*)elementName
|
|
associations:(NSDictionary*)associations
|
|
template:(GSWElement*)templateElement
|
|
{
|
|
LOGObjectFnStartC("GSWHTMLDynamicElement");
|
|
NSDebugMLLog(@"gswdync",@"elementName=[%@] associations=[%@] templateElement=[%@]",
|
|
elementName,associations,templateElement);
|
|
//OK
|
|
if ((self=[self initWithName:elementName
|
|
associations:associations
|
|
contentElements:templateElement ? [NSArray arrayWithObject:templateElement] : nil]))
|
|
{
|
|
};
|
|
LOGObjectFnStopC("GSWHTMLDynamicElement");
|
|
return self;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)dealloc
|
|
{
|
|
DESTROY(_elementsMap);
|
|
DESTROY(_htmlBareStrings);
|
|
DESTROY(_dynamicChildren);
|
|
DESTROY(_attributeAssociations);
|
|
[super dealloc];
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(id)_initWithElementsMap:(NSData*)elementsMap
|
|
htmlBareStrings:(NSArray*)htmlBareStrings
|
|
dynamicChildren:(NSArray*)dynamicChildren
|
|
attributeAssociations:(NSArray*)attributeAssociations
|
|
{
|
|
BOOL compactHTMLTags=NO;
|
|
BOOL hasGSWebObjectsAssociations=NO;
|
|
int GSWebObjectsAssociationsCount=0;
|
|
LOGObjectFnStartC("GSWHTMLDynamicElement");
|
|
NSDebugMLLog(@"gswdync",@"elementsMap=%@ htmlBareStrings:%@ dynamicChildren=%@ attributeAssociations=%@",
|
|
elementsMap,
|
|
htmlBareStrings,
|
|
dynamicChildren,
|
|
attributeAssociations);
|
|
compactHTMLTags=[self compactHTMLTags];
|
|
//OK
|
|
if (compactHTMLTags)
|
|
{
|
|
int elementN=0;
|
|
while(elementN<[elementsMap length] && ((BYTE*)[elementsMap bytes])[elementN]==ElementsMap_htmlBareString)
|
|
elementN++;
|
|
NSDebugMLLog(@"gswdync",@"elementN=%d",elementN);
|
|
[self _setEndOfHTMLTag:elementN];
|
|
if (elementN>0)
|
|
{
|
|
int rmStringN=0;
|
|
NSMutableArray* rmStrings=[NSMutableArray array];
|
|
NSMutableString* rmString=[[NSMutableString new] autorelease];
|
|
NSMutableData* tmpElementsMap=[[NSMutableData new] autorelease];
|
|
NSDebugMLLog(@"gswdync",@"XXXXXX");//XXXXXXX
|
|
[tmpElementsMap appendBytes:&ElementsMap_htmlBareString
|
|
length:1];
|
|
if ([elementsMap length]>elementN)
|
|
[tmpElementsMap appendData:[elementsMap subdataWithRange:
|
|
NSMakeRange(elementN,
|
|
[elementsMap length]-elementN)]];
|
|
NSDebugMLLog(@"gswdync",@"XXXXXX");//XXXXXXX
|
|
elementsMap=tmpElementsMap;
|
|
for(rmStringN=0;rmStringN<elementN;rmStringN++)
|
|
{
|
|
NSDebugMLLog(@"gswdync",@"XXXXXX");//XXXXXXX
|
|
NSDebugMLLog(@"gswdync",@"rmString=%@ [_htmlBareStrings objectAtIndex:rmStringN]=%@",
|
|
rmString,
|
|
[htmlBareStrings objectAtIndex:rmStringN]);
|
|
[rmString appendString:[htmlBareStrings objectAtIndex:rmStringN]];
|
|
};
|
|
NSDebugMLLog(@"gswdync",@"XXXXXX");//XXXXXXX
|
|
[rmStrings addObject:rmString];
|
|
NSDebugMLLog(@"gswdync",@"rmStrings=%@",rmStrings);
|
|
for(rmStringN=elementN;rmStringN<[htmlBareStrings count];rmStringN++)
|
|
{
|
|
NSDebugMLLog(@"gswdync",@"rmStrings=%@ [htmlBareStrings objectAtIndex:rmStringN]=%@",
|
|
rmStrings,
|
|
[htmlBareStrings objectAtIndex:rmStringN]);
|
|
[rmStrings addObject:[htmlBareStrings objectAtIndex:rmStringN]];
|
|
};
|
|
NSDebugMLLog(@"gswdync",@"XXXXXX");//XXXXXXX
|
|
htmlBareStrings=rmStrings;
|
|
NSDebugMLLog(@"gswdync",@"elementsMap=%@ htmlBareStrings:%@",
|
|
elementsMap,
|
|
htmlBareStrings);
|
|
};
|
|
};
|
|
NSDebugMLLog(@"gswdync",@"XXXXXX");//XXXXXXX
|
|
[self setHtmlBareStrings:htmlBareStrings];
|
|
GSWebObjectsAssociationsCount=[self GSWebObjectsAssociationsCount];
|
|
if (GSWebObjectsAssociationsCount>0)
|
|
hasGSWebObjectsAssociations=YES;
|
|
else
|
|
hasGSWebObjectsAssociations=[[self class]hasGSWebObjectsAssociations];
|
|
if (hasGSWebObjectsAssociations)
|
|
{
|
|
//TODO
|
|
};
|
|
|
|
ASSIGN(_elementsMap,elementsMap);
|
|
|
|
ASSIGN(_dynamicChildren,dynamicChildren);
|
|
ASSIGN(_attributeAssociations,attributeAssociations);
|
|
|
|
LOGObjectFnStopC("GSWHTMLDynamicElement");
|
|
return self;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(NSString*)elementName
|
|
{
|
|
//OK
|
|
[self subclassResponsibility:_cmd];
|
|
return nil;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(NSArray*)dynamicChildren
|
|
{
|
|
//OK
|
|
return _dynamicChildren;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(NSArray*)htmlBareStrings
|
|
{
|
|
//OK
|
|
return _htmlBareStrings;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(NSData*)elementsMap
|
|
{
|
|
//OK
|
|
return _elementsMap;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(NSArray*)attributeAssociations
|
|
{
|
|
//OK
|
|
return _attributeAssociations;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)_setEndOfHTMLTag:(unsigned int)unknown
|
|
{
|
|
LOGObjectFnStartC("GSWHTMLDynamicElement");
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
LOGObjectFnStopC("GSWHTMLDynamicElement");
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(NSString*)description
|
|
{
|
|
return [NSString stringWithFormat:@"<%@ %p elementsMap:%@ htmlBareStrings:%@ dynamicChildren:%@ attributeAssociations:%@>",
|
|
[self class],
|
|
(void*)self,
|
|
_elementsMap,
|
|
_htmlBareStrings,
|
|
_dynamicChildren,
|
|
_attributeAssociations];
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)setHtmlBareStrings:(NSArray*)htmlBareStrings
|
|
{
|
|
ASSIGN(_htmlBareStrings,htmlBareStrings);
|
|
};
|
|
|
|
|
|
@end
|
|
|
|
//====================================================================
|
|
@implementation GSWHTMLDynamicElement (GSWHTMLDynamicElementA)
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)aResponse
|
|
inContext:(GSWContext*)aContext
|
|
{
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(unsigned int)GSWebObjectsAssociationsCount
|
|
{
|
|
return 1;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)appendToResponse:(GSWResponse*)aResponse
|
|
inContext:(GSWContext*)aContext
|
|
{
|
|
//OK
|
|
LOGObjectFnStartC("GSWHTMLDynamicElement");
|
|
GSWStartElement(aContext);
|
|
GSWSaveAppendToResponseElementID(aContext);//Debug Only
|
|
if ([_elementsMap length]>0)
|
|
{
|
|
[self appendToResponse:aResponse
|
|
inContext:aContext
|
|
elementsFromIndex:0
|
|
toIndex:[_elementsMap length]-1];
|
|
};
|
|
GSWStopElement(aContext);
|
|
LOGObjectFnStopC("GSWHTMLDynamicElement");
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)appendToResponse:(GSWResponse*)aResponse
|
|
inContext:(GSWContext*)aContext
|
|
elementsFromIndex:(unsigned int)fromIndex
|
|
toIndex:(unsigned int)toIndex
|
|
{
|
|
//OK
|
|
NSStringEncoding encoding=0;
|
|
NSArray* dynamicChildren=nil;
|
|
GSWComponent* component=nil;
|
|
GSWRequest* request=nil;
|
|
BOOL isFromClientComponent=NO;
|
|
NSArray* attributeAssociations=nil;
|
|
int elementN=0;
|
|
const BYTE* elements=[_elementsMap bytes];
|
|
BYTE element=0;
|
|
int elementsN[4]={0,0,0,0};
|
|
BOOL inChildren=NO;
|
|
#ifndef NDEBUG
|
|
NSString* debugElementID=nil;
|
|
#endif
|
|
LOGObjectFnStartC("GSWHTMLDynamicElement");
|
|
|
|
encoding=[aResponse contentEncoding];
|
|
dynamicChildren=[self dynamicChildren];//call dynamicChildren //GSWTextField: nil
|
|
NSDebugMLLog(@"gswdync",@"dynamicChildren=%@",dynamicChildren);
|
|
component=[aContext component];
|
|
request=[aContext request];
|
|
isFromClientComponent=[request isFromClientComponent]; //return NO
|
|
attributeAssociations=[self attributeAssociations]; //return nil for GSWTextField/GSWSubmitButton;
|
|
|
|
NSAssert2(fromIndex<[_elementsMap length],@"fromIndex out of range:%u (length=%d)",
|
|
fromIndex,[_elementsMap length]);
|
|
NSAssert2(toIndex<[_elementsMap length],@"toIndex out of range:%u (length=%d)",
|
|
toIndex,[_elementsMap length]);
|
|
NSAssert2(fromIndex<=toIndex,@"fromIndex>toIndex %u %u ",
|
|
fromIndex,toIndex);
|
|
NSDebugMLLog(@"gswdync",@"Starting HTMLDyn AR ET=%@ id=%@",
|
|
[self class],[aContext elementID]);
|
|
for(elementN=0;elementN<=toIndex;elementN++)
|
|
{
|
|
element=(BYTE)elements[elementN];
|
|
NSDebugMLLog(@"gswdync",@"elements=%c",element);
|
|
if (element==ElementsMap_dynamicElement)
|
|
{
|
|
if (!inChildren)
|
|
{
|
|
#ifndef NDEBUG
|
|
debugElementID=[aContext elementID];
|
|
#endif
|
|
[aContext appendZeroElementIDComponent];
|
|
inChildren=YES;
|
|
};
|
|
}
|
|
else
|
|
{
|
|
if (inChildren)
|
|
{
|
|
[aContext deleteLastElementIDComponent];
|
|
inChildren=NO;
|
|
#ifndef NDEBUG
|
|
if (![debugElementID isEqualToString:[aContext elementID]])
|
|
{
|
|
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
|
|
[self class],debugElementID,[aContext elementID]);
|
|
|
|
};
|
|
#endif
|
|
};
|
|
};
|
|
if (element==ElementsMap_htmlBareString)
|
|
{
|
|
if (elementN>=fromIndex)
|
|
[aResponse appendContentString:[_htmlBareStrings objectAtIndex:elementsN[0]]];
|
|
elementsN[0]++;
|
|
}
|
|
else if (element==ElementsMap_gswebElement)
|
|
{
|
|
if (elementN>=fromIndex)
|
|
[self appendGSWebObjectsAssociationsToResponse:aResponse
|
|
inContext:aContext];
|
|
elementsN[1]++;
|
|
}
|
|
else if (element==ElementsMap_dynamicElement)
|
|
{
|
|
if (elementN>=fromIndex)
|
|
{
|
|
NSDebugMLLog(@"gswdync",@"appendToResponse i=%d",
|
|
elementN);
|
|
[[dynamicChildren objectAtIndex:elementsN[2]] appendToResponse:aResponse
|
|
inContext:aContext];
|
|
[aContext incrementLastElementIDComponent];
|
|
};
|
|
elementsN[2]++;
|
|
}
|
|
else if (element==ElementsMap_attributeElement)
|
|
{
|
|
if (elementN>=fromIndex)
|
|
{
|
|
GSWAssociation* association=[_attributeAssociations objectAtIndex:elementsN[3]];
|
|
id value=[association valueInComponent:component];
|
|
if (value)
|
|
{
|
|
[aResponse appendContentString:@"=\""];
|
|
[aResponse appendContentHTMLAttributeValue:value];
|
|
[aResponse appendContentString:@"\""];
|
|
};
|
|
};
|
|
elementsN[3]++;
|
|
};
|
|
};
|
|
if (inChildren)
|
|
{
|
|
[aContext deleteLastElementIDComponent];
|
|
#ifndef NDEBUG
|
|
if (![debugElementID isEqualToString:[aContext elementID]])
|
|
{
|
|
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
|
|
[self class],debugElementID,[aContext elementID]);
|
|
};
|
|
#endif
|
|
};
|
|
GSWStopElement(aContext);
|
|
LOGObjectFnStopC("GSWHTMLDynamicElement");
|
|
};
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
-(GSWElement*)invokeActionForRequest:(GSWRequest*)aRequest
|
|
inContext:(GSWContext*)aContext
|
|
{
|
|
//???
|
|
GSWElement* element=nil;
|
|
NSString* senderID=nil;
|
|
LOGObjectFnStartC("GSWHTMLDynamicElement");
|
|
GSWStartElement(aContext);
|
|
GSWAssertCorrectElementID(aContext);// Debug Only
|
|
senderID=[aContext senderID];
|
|
if ([_elementsMap length]>0)
|
|
{
|
|
int elementN=0;
|
|
NSArray* dynamicChildren=[self dynamicChildren];
|
|
const BYTE* elements=[_elementsMap bytes];
|
|
BYTE elementIndic=0;
|
|
int elementsN[4]={0,0,0,0};
|
|
BOOL searchIsOver=NO;
|
|
BOOL inChildren=NO;
|
|
#ifndef NDEBUG
|
|
NSString* debugElementID=nil;
|
|
#endif
|
|
for(elementN=0;!element && !searchIsOver && elementN<[_elementsMap length];elementN++)
|
|
{
|
|
elementIndic=(BYTE)elements[elementN];
|
|
if (elementIndic==ElementsMap_dynamicElement)
|
|
{
|
|
if (!inChildren)
|
|
{
|
|
#ifndef NDEBUG
|
|
debugElementID=[aContext elementID];
|
|
#endif
|
|
[aContext appendZeroElementIDComponent];
|
|
inChildren=YES;
|
|
};
|
|
}
|
|
else
|
|
{
|
|
if (inChildren)
|
|
{
|
|
[aContext deleteLastElementIDComponent];
|
|
inChildren=NO;
|
|
#ifndef NDEBUG
|
|
if (![debugElementID isEqualToString:[aContext elementID]])
|
|
{
|
|
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
|
|
[self class],
|
|
debugElementID,
|
|
[aContext elementID]);
|
|
|
|
};
|
|
#endif
|
|
};
|
|
};
|
|
if (elementIndic==ElementsMap_htmlBareString)
|
|
elementsN[0]++;
|
|
else if (elementIndic==ElementsMap_gswebElement)
|
|
elementsN[1]++;
|
|
else if (elementIndic==ElementsMap_dynamicElement)
|
|
{
|
|
element=[[dynamicChildren objectAtIndex:elementsN[2]] invokeActionForRequest:aRequest
|
|
inContext:aContext];
|
|
if (![aContext _wasFormSubmitted] && [[aContext elementID] isSearchOverForSenderID:senderID])
|
|
{
|
|
NSDebugMLLog(@"gswdync",@"id=%@ senderid=%@ => search is over",
|
|
[aContext elementID],
|
|
senderID);
|
|
searchIsOver=YES;
|
|
};
|
|
[aContext incrementLastElementIDComponent];
|
|
elementsN[2]++;
|
|
}
|
|
else if (elementIndic==ElementsMap_attributeElement)
|
|
elementsN[3]++;
|
|
};
|
|
if (inChildren)
|
|
{
|
|
[aContext deleteLastElementIDComponent];
|
|
#ifndef NDEBUG
|
|
if (![debugElementID isEqualToString:[aContext elementID]])
|
|
{
|
|
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
|
|
[self class],debugElementID,[aContext elementID]);
|
|
|
|
};
|
|
#endif
|
|
};
|
|
};
|
|
GSWStopElement(aContext);
|
|
NSDebugMLLog(@"gswdync",@"senderID=%@",[aContext senderID]);
|
|
LOGObjectFnStopC("GSWHTMLDynamicElement");
|
|
return element;
|
|
};
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)takeValuesFromRequest:(GSWRequest*)aRequest
|
|
inContext:(GSWContext*)aContext
|
|
{
|
|
LOGObjectFnStartC("GSWHTMLDynamicElement");
|
|
GSWStartElement(aContext);
|
|
GSWAssertCorrectElementID(aContext);
|
|
if ([_elementsMap length]>0)
|
|
{
|
|
int elementN=0;
|
|
NSArray* dynamicChildren=[self dynamicChildren];
|
|
const BYTE* elements=[_elementsMap bytes];
|
|
BYTE element=0;
|
|
int elementsN[4]={0,0,0,0};
|
|
BOOL inChildren=NO;
|
|
#ifndef NDEBUG
|
|
NSString* debugElementID=nil;
|
|
#endif
|
|
for(elementN=0;elementN<[_elementsMap length];elementN++)
|
|
{
|
|
element=(BYTE)elements[elementN];
|
|
if (element==ElementsMap_dynamicElement)
|
|
{
|
|
if (!inChildren)
|
|
{
|
|
#ifndef NDEBUG
|
|
debugElementID=[aContext elementID];
|
|
#endif
|
|
[aContext appendZeroElementIDComponent];
|
|
inChildren=YES;
|
|
};
|
|
}
|
|
else
|
|
{
|
|
if (inChildren)
|
|
{
|
|
[aContext deleteLastElementIDComponent];
|
|
inChildren=NO;
|
|
#ifndef NDEBUG
|
|
if (![debugElementID isEqualToString:[aContext elementID]])
|
|
{
|
|
NSDebugMLLog(@"gswdync",@"ERROR class=%@ debugElementID=%@ [aContext elementID]=%@",
|
|
[self class],debugElementID,[aContext elementID]);
|
|
};
|
|
#endif
|
|
};
|
|
};
|
|
|
|
if (element==ElementsMap_htmlBareString)
|
|
elementsN[0]++;
|
|
else if (element==ElementsMap_gswebElement)
|
|
elementsN[1]++;
|
|
else if (element==ElementsMap_dynamicElement)
|
|
{
|
|
NSDebugMLLog(@"gswdync",@"i=%d",
|
|
elementN);
|
|
[[dynamicChildren objectAtIndex:elementsN[2]] takeValuesFromRequest:aRequest
|
|
inContext:aContext];
|
|
[aContext incrementLastElementIDComponent];
|
|
elementsN[2]++;
|
|
}
|
|
else if (element==ElementsMap_attributeElement)
|
|
elementsN[3]++;
|
|
};
|
|
if (inChildren)
|
|
{
|
|
[aContext deleteLastElementIDComponent];
|
|
#ifndef NDEBUG
|
|
if (![debugElementID isEqualToString:[aContext elementID]])
|
|
{
|
|
NSDebugMLLog(@"gswdync",@"class=%@ debugElementID=%@ [aContext elementID]=%@",
|
|
[self class],debugElementID,[aContext elementID]);
|
|
};
|
|
#endif
|
|
};
|
|
};
|
|
GSWStopElement(aContext);
|
|
LOGObjectFnStopC("GSWHTMLDynamicElement");
|
|
};
|
|
|
|
@end
|
|
|
|
//====================================================================
|
|
@implementation GSWHTMLDynamicElement (GSWHTMLDynamicElementB)
|
|
|
|
//--------------------------------------------------------------------
|
|
-(BOOL)compactHTMLTags
|
|
{
|
|
return YES;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(BOOL)appendStringAtRight:(id)unkwnon
|
|
withMapping:(char*)mapping
|
|
{
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
return NO;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(BOOL)appendStringAtLeft:(id)unkwnon
|
|
withMapping:(char*)mapping
|
|
{
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
return NO;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(BOOL)canBeFlattenedAtInitialization
|
|
{
|
|
LOGObjectFnNotImplemented(); //TODOFN
|
|
return NO;
|
|
};
|
|
|
|
@end
|
|
|
|
//====================================================================
|
|
@implementation GSWHTMLDynamicElement (GSWHTMLDynamicElementC)
|
|
|
|
//--------------------------------------------------------------------
|
|
+(void)setDynamicElementCompaction:(BOOL)flag
|
|
{
|
|
LOGClassFnNotImplemented(); //TODOFN
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
+(BOOL)escapeHTML
|
|
{
|
|
//OK?
|
|
return NO;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
+(BOOL)hasGSWebObjectsAssociations
|
|
{
|
|
//OK ?
|
|
return NO;
|
|
};
|
|
|
|
@end
|
|
|
|
|
|
//====================================================================
|
|
//@implementation GSWHTMLDynamicElement (GSWHTMLDynamicElementD)
|
|
// move it to GSWHTMLDynamicElement later !!!!
|
|
|
|
@implementation GSWDynamicElement (GSWHTMLDynamicElementD)
|
|
//--------------------------------------------------------------------
|
|
-(NSString*)computeActionStringWithActionClassAssociation:(GSWAssociation*)actionClass
|
|
directActionNameAssociation:(GSWAssociation*)directActionName
|
|
inContext:(GSWContext*)context
|
|
{
|
|
//OK
|
|
GSWComponent* component=nil;
|
|
id tmpDirectActionString=nil;
|
|
id directActionNameValue=nil;
|
|
id actionClassValue=nil;
|
|
LOGObjectFnStart();
|
|
component=[context component];
|
|
if (directActionName)
|
|
directActionNameValue=[directActionName valueInComponent:component];
|
|
if (actionClass)
|
|
actionClassValue=[actionClass valueInComponent:component];
|
|
|
|
if (actionClassValue)
|
|
{
|
|
if (directActionNameValue)
|
|
tmpDirectActionString=[NSString stringWithFormat:@"%@/%@",
|
|
actionClassValue,
|
|
directActionNameValue];
|
|
else
|
|
tmpDirectActionString=actionClassValue;
|
|
}
|
|
else if (directActionNameValue)
|
|
tmpDirectActionString=directActionNameValue;
|
|
else
|
|
{
|
|
LOGSeriousError(@"No actionClass (for %@) and no directActionName (for %@)",
|
|
actionClass,
|
|
directActionName);
|
|
};
|
|
|
|
NSDebugMLLog(@"gswdync",@"tmpDirectActionString=%@",tmpDirectActionString);
|
|
LOGObjectFnStop();
|
|
return tmpDirectActionString;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(NSDictionary*)computeQueryDictionaryWithActionClassAssociation:(GSWAssociation*)actionClass
|
|
directActionNameAssociation:(GSWAssociation*)directActionName
|
|
queryDictionaryAssociation:(GSWAssociation*)queryDictionary
|
|
otherQueryAssociations:(NSDictionary*)otherQueryAssociations
|
|
inContext:(GSWContext*)context
|
|
{
|
|
//OK
|
|
NSMutableDictionary* finalQueryDictionary=nil;
|
|
GSWComponent* component=nil;
|
|
GSWSession* session=nil;
|
|
NSString* sessionID=nil;
|
|
LOGObjectFnStart();
|
|
|
|
NSDebugMLLog(@"gswdync",@"actionClass=%@",actionClass);
|
|
NSDebugMLLog(@"gswdync",@"directActionName=%@",directActionName);
|
|
NSDebugMLLog(@"gswdync",@"queryDictionary=%@",queryDictionary);
|
|
NSDebugMLLog(@"gswdync",@"otherQueryAssociations=%@",otherQueryAssociations);
|
|
|
|
component=[context component];
|
|
session=[context existingSession];
|
|
NSDebugMLog(@"session=%@",session);
|
|
|
|
if (queryDictionary)
|
|
{
|
|
NSDictionary* queryDictionaryValue=[queryDictionary valueInComponent:component];
|
|
if (queryDictionaryValue)
|
|
{
|
|
if ([queryDictionaryValue isKindOfClass:[NSMutableDictionary class]])
|
|
finalQueryDictionary=(NSMutableDictionary*)queryDictionaryValue;
|
|
else
|
|
{
|
|
NSAssert3([queryDictionaryValue isKindOfClass:[NSDictionary class]],
|
|
@"queryDictionary value is not a dictionary but a %@. association was: %@. queryDictionaryValue is:",
|
|
[queryDictionaryValue class],
|
|
queryDictionary,
|
|
queryDictionaryValue);
|
|
finalQueryDictionary=[[queryDictionaryValue mutableCopy] autorelease];
|
|
};
|
|
};
|
|
};
|
|
if (!finalQueryDictionary)
|
|
finalQueryDictionary=(NSMutableDictionary*)[NSMutableDictionary dictionary];
|
|
|
|
if (session)
|
|
sessionID=[session sessionID];
|
|
NSDebugMLog(@"sessionID=%@",sessionID);
|
|
/*
|
|
in GSWHyperlink, it was
|
|
if (!_action && !_pageName
|
|
&& (WOStrictFlag || (!WOStrictFlag && !_redirectURL))) //??
|
|
*/
|
|
if(sessionID
|
|
&& (directActionName || actionClass)
|
|
&& (!session || ![session storesIDsInCookies] || [session storesIDsInURLs]))
|
|
[finalQueryDictionary setObject:sessionID
|
|
forKey:GSWKey_SessionID[GSWebNamingConv]];
|
|
|
|
if (otherQueryAssociations)
|
|
{
|
|
NSEnumerator *enumerator = [otherQueryAssociations keyEnumerator];
|
|
id associationKey=nil;
|
|
while ((associationKey = [enumerator nextObject]))
|
|
{
|
|
id association = [otherQueryAssociations valueForKey:associationKey];
|
|
id associationValue=[association valueInComponent:component];
|
|
NSDebugMLLog(@"gswdync",@"associationKey=%@",associationKey);
|
|
NSDebugMLLog(@"gswdync",@"association=%@",association);
|
|
NSDebugMLLog(@"gswdync",@"associationValue=%@",associationValue);
|
|
if (!associationValue)
|
|
associationValue=[NSString string];
|
|
[finalQueryDictionary setObject:associationValue
|
|
forKey:associationKey];
|
|
};
|
|
};
|
|
|
|
LOGObjectFnStop();
|
|
return finalQueryDictionary;
|
|
};
|
|
@end
|