mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-02-22 11:11:21 +00:00
* GSWeb.framework/GSWGNUmakefile: o removed NSObject+IVarAccess+PerformSel.* * GSWeb.framework/GSWConstants.m: o fix GSWHTTPHeader_Response_HeaderLineEnd: remove space at the begining o use RCS_ID * GSWeb.framework/Adaptors/common/GSWHTTPResponse.c: o fix status in GSWHTTPResponse_New() * GSWAdaptors/Apache/mod_gsweb.c: o fixes bad returned status o traces * GSWeb.framework/GSWTemplateParserANTLR.m: o removed logs o fixes for warnings o use RCS_ID * GSWeb.framework/GSWApplication.m: o use RCS_ID o added logs o new method to begin rewrite exception handling * GSWeb.framework/GSWRequest.m: o logs o fix in -_getFormValuesFromMultipartFormData to handle more than one value per name o use RCS_ID o -fix bad types in uriElementForKey: * GSWeb.framework/GSWConditional.m: o added asserts o use RCS_ID * GSWeb.framework/GSWHTMLStaticElement.m: o added asserts o clean warnings o use RCS_ID * GSWeb.framework/GSWComponentReference.m: o added asserts o use RCS_ID * GSWeb.framework/GSWActiveImage.m: o added asserts * GSWeb.framework/GSWComponentContent.m: o added asserts o use RCS_ID * GSWeb.framework/GSWForm.m: o added asserts o use RCS_ID * GSWeb.framework/GSWHTMLDynamicElement.m: o added asserts o use RCS_ID * GSWeb.framework/GSWHTMLURLValuedElement.m: o use RCS_ID o added asserts * GSWeb.framework/GSWRepetition.m: o added asserts o use RCS_ID * GSWeb.framework/GSWExtensions.framework/GNUmakefile: o added GSWPageRestorationErrorPage.gswc * GSWeb.framework/GSWFileUploadComponent.m: o use RCS_ID * GSWeb.framework/GSWImage.m: o Don't output nil height/width o fix: get component before using ! o use RCS_ID * GSWeb.framework/GSWElementIDString.m: o in -initWithCoder: retain _string o use RCS_ID * GSWeb.framework/GSWElementIDString.h: o cleaned * config.h.in: o define RCS_ID like in GDL2 * GSWeb.framework/GSWDirectActionRequestHandler.[hm]: o added +additionalRequestPathArrayFromRequest: o enable directAction with additional path components o use RCS_ID * GSWeb.framework/GSWDirectAction.[hm]: o added -additionalRequestPathArray o use RCS_ID * GSWeb.framework/GSWeb.h: o include GSCategories.h * GSWeb.framework/GSWDebug.m: o use RCS_ID * GSWeb.framework/GSWPageDefParserExt.m: o use RCS_ID * GSWeb.framework/GSWPageDefElement.m: o use RCS_ID * GSWeb.framework/GSWDeployedBundle.m: o use RCS_ID * GSWeb.framework/GSWProjectBundle.m: o use RCS_ID * GSWeb.framework/GSWStats.m: o use RCS_ID * GSWeb.framework/GSWBundle.m: o clean warnings o use RCS_ID * GSWeb.framework/GSWTemplateParser.m:: o clean warnings o use RCS_ID * GSWeb.framework/GSWTemplateParserXML.m: o clean warnings o use RCS_ID * GSWeb.framework/GSWComponent.m: o clean warnings o use RCS_ID * GSWeb.framework/GSWDisplayGroup.m: o clean warnings o fix -validateValue:forKey: call o use RCS_ID * GSWeb.framework/GSWHTMLParserExt.m: o use RCS_ID * GSWeb.framework/GSWAssociation.m: o clean warnings o use RCS_ID * GSWeb.framework/GSWResourceManager.m: o clean warnings o use RCS_ID * GSWeb.framework/GSWSession.m: o clean warnings o use RCS_ID * GSWeb.framework/GSWMultiKeyDictionary.m: o use RCS_ID * GSWeb.framework/GSWResponse.m: o clean warnings o use RCS_ID * GSWeb.framework/GSWStatisticsStore.m: o clean warnings * GSWeb.framework/GSWAdaptor.m: o use RCS_ID * GSWeb.framework/GSWGeometricRegion.[hm]: o types change o use RCS_ID * GSWeb.framework/GSWActiveImage.m: o clean warnings o use RCS_ID * GSWeb.framework/GSWBody.m: o use RCS_ID * GSWeb.framework/GSWTextField.m: o use RCS_ID * GSWeb.framework/GSWSubmitButton.m: o clean warnings o use RCS_ID * GSWeb.framework/GSWHTMLBareString.m: o use RCS_ID * GSWeb.framework/GSWHTMLComment.m: o use RCS_ID * GSWeb.framework/GSWApplet.m: o use RCS_ID * GSWeb.framework/GSWBrowser.m: o use RCS_ID * GSWeb.framework/GSWCheckBoxList.m: o use RCS_ID * GSWeb.framework/GSWEmbeddedObject.m: o use RCS_ID * GSWeb.framework/GSWFrame.m: o use RCS_ID * GSWeb.framework/GSWGenericContainer.m: o use RCS_ID * GSWeb.framework/GSWGenericElement.m: o use RCS_ID * GSWeb.framework/GSWHyperlink.m: o use RCS_ID o clean warnings * GSWeb.framework/GSWImageButton.m: o use RCS_ID o clean warnings * GSWeb.framework/GSWJavaScript.m: o use RCS_ID * GSWeb.framework/GSWNestedList.m: o use RCS_ID * GSWeb.framework/GSWParam.m: o use RCS_ID * GSWeb.framework/GSWPasswordField.m: o use RCS_ID * GSWeb.framework/GSWPopUpButton.m: o use RCS_ID * GSWeb.framework/GSWRadioButtonList.m: o use RCS_ID * GSWeb.framework/GSWResetButton.m: o use RCS_ID * GSWeb.framework/GSWSwitchComponent.m: o use RCS_ID * GSWeb.framework/GSWVBScript.m: o use RCS_ID * GSWeb.framework/GSWString.m: o use RCS_ID * GSWeb.framework/GSWText.m: o use RCS_ID * GSWeb.framework/GSWCookie.m: o use RCS_ID * GSWeb.framework/GSWRequestHandler.m: o use RCS_ID * GSWeb.framework/GSWMailDelivery.m: o use RCS_ID * GSWeb.framework/GSWComponentRequestHandler.m: o use RCS_ID o clean warnings * GSWeb.framework/GSWKeyValueAssociation.m: o use RCS_ID * GSWeb.framework/GSWHTMLStaticGroup.m: o use RCS_ID * GSWeb.framework/GSWConstantValueAssociation.m: o use RCS_ID * GSWeb.framework/GSWDynamicURLString.m: o use RCS_ID * GSWeb.framework/GSWBindingNameAssociation.m: o use RCS_ID * GSWeb.framework/GSWBindingNameAssociation.[hm] o clean warnings o use RCS_ID * GSWeb.framework/GSWURLValuedElementData.m: o clean warnings o use RCS_ID * GSWeb.framework/GSWToggle.m: o use RCS_ID * GSWeb.framework/GSWFileUpload.m: o use RCS_ID * GSWeb.framework/GSWResourceURL.m: o use RCS_ID * GSWeb.framework/GSWProcFS.m: o use RCS_ID * GSWeb.framework/GSWActionURL.m: o use RCS_ID * GSWeb.framework/GSWContext.m: o use RCS_ID * GSWeb.framework/GSWDefaultAdaptorThread.m: o use RCS_ID * GSWeb.framework/GSWDynamicElement.m: o use RCS_ID * GSWeb.framework/GSWeb.m: o use RCS_ID * GSWeb.framework/GSWElement.m: o use RCS_ID * GSWeb.framework/GSWResourceRequestHandler.m: o use RCS_ID * GSWeb.framework/GSWServerSessionStore.m: o use RCS_ID * GSWeb.framework/GSWSessionStore.m: o use RCS_ID * GSWeb.framework/GSWSessionTimeOut.m: o use RCS_ID * GSWeb.framework/GSWSessionTimeOutManager.m: o use RCS_ID * GSWeb.framework/GSWTransactionRecord.m: o use RCS_ID * GSWeb.framework/GSWUtils.m: o use RCS_ID * GSWeb.framework/GSWWOCompatibility.m: o use RCS_ID * GSWeb.framework/NSString+HTML.m: o use RCS_ID * GSWeb.framework/NSString+Trimming.m: o use RCS_ID git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@16216 72102866-910b-0410-8b05-ffd578937521
876 lines
30 KiB
Objective-C
876 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>
|
|
**/
|
|
|
|
#include "config.h"
|
|
|
|
RCS_ID("$Id$")
|
|
|
|
#include "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];
|
|
NSAssert3(!element || [element isKindOfClass:[GSWElement class]],
|
|
@"From: %@ Element is a %@ not a GSWElement: %@",
|
|
[dynamicChildren objectAtIndex:elementsN[2]],
|
|
[element class],
|
|
element);
|
|
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
|