mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-02-24 04:01:16 +00:00
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
265 lines
7.5 KiB
Objective-C
265 lines
7.5 KiB
Objective-C
/** GSWURLValuedElementData.m - <title>GSWeb: Class GSWURLValuedElementData</title>
|
|
|
|
Copyright (C) 1999-2005 Free Software Foundation, Inc.
|
|
|
|
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
|
|
Date: Jan 1999
|
|
|
|
$Revision$
|
|
$Date$
|
|
|
|
<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"
|
|
|
|
//====================================================================
|
|
|
|
static Class NSStringClass = Nil;
|
|
|
|
@implementation GSWURLValuedElementData
|
|
|
|
+ (void) initialize
|
|
{
|
|
if (self == [GSWURLValuedElementData class])
|
|
{
|
|
NSStringClass = [NSString class];
|
|
}
|
|
}
|
|
|
|
// checkme if 0 is the right value in GSW for unused applicationNumber
|
|
// checkme: does this exists in WO4.5?
|
|
// dataURL
|
|
- (NSString*) dataURLInContext:(GSWContext *) context
|
|
{
|
|
int appNr = 0;
|
|
NSString * appNrStr = nil;
|
|
GSWDynamicURLString * url = nil;
|
|
GSWDynamicURLString * url2 = nil;
|
|
NSMutableString * myStr = [NSMutableString stringWithCapacity:80];
|
|
|
|
NSLog(@"is this code ever used? -- dw (%s)",__PRETTY_FUNCTION__ );
|
|
|
|
|
|
[myStr appendString: GSWKey_Data[GSWebNamingConv]]; //wodata
|
|
[myStr appendString:@"="];
|
|
[myStr appendString:[[self key] encodeURL]];
|
|
|
|
appNr = [[context request] applicationNumber];
|
|
if (appNr > 0) {
|
|
url = [context _url];
|
|
appNrStr = [url applicationNumber];
|
|
// with our current URLString it is a bit waste of time but that is how others to it.
|
|
[url setApplicationNumber: GSWIntToNSString(appNr)];
|
|
}
|
|
|
|
url2 = [context urlWithRequestHandlerKey:[[GSWApp class] resourceRequestHandlerKey]
|
|
path: nil
|
|
queryString: myStr];
|
|
|
|
if (appNr > 0) {
|
|
[url setApplicationNumber:appNrStr];
|
|
}
|
|
return url2;
|
|
}
|
|
|
|
|
|
|
|
+ (NSString*) _dataURLInContext: (GSWContext*) context
|
|
key:(GSWAssociation*) key
|
|
data:(GSWAssociation*) data
|
|
mimeType:(GSWAssociation*) mimeType
|
|
inComponent:(GSWComponent*) component
|
|
{
|
|
id obj = nil;
|
|
NSString * str = nil;
|
|
NSString * keyStr = nil;
|
|
NSString * mimeValue = nil;
|
|
GSWResourceManager * resourcemanager = [GSWApp resourceManager];
|
|
if (key != nil) {
|
|
id keyValue = [key valueInComponent:component];
|
|
if (keyValue != nil) {
|
|
keyStr = [keyValue description];
|
|
}
|
|
}
|
|
if (keyStr != nil) {
|
|
obj = [resourcemanager _cachedDataForKey: keyStr];
|
|
}
|
|
if (obj == nil) {
|
|
NSData * nsdataValue = [data valueInComponent:component];
|
|
|
|
mimeValue = [mimeType valueInComponent:component];
|
|
if (nsdataValue != nil && mimeValue != nil) {
|
|
obj = [[GSWURLValuedElementData alloc] initWithData: nsdataValue
|
|
mimeType: mimeValue
|
|
key: keyStr];
|
|
AUTORELEASE(obj);
|
|
|
|
if (obj != nil) {
|
|
[resourcemanager _cacheData:obj];
|
|
}
|
|
}
|
|
}
|
|
if (obj == nil) {
|
|
obj = @"/ERROR/NOT_FOUND/DYNAMIC_DATA";
|
|
return obj;
|
|
}
|
|
if ([obj isKindOfClass:NSStringClass]) {
|
|
return obj;
|
|
} else {
|
|
str = [(GSWURLValuedElementData*) obj dataURLInContext:context];
|
|
}
|
|
return str;
|
|
}
|
|
|
|
|
|
|
|
// _appendDataURLAttributeToResponse
|
|
+ (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
|
|
data: data
|
|
mimeType: mimeType
|
|
inComponent: component];
|
|
|
|
|
|
GSWResponse_appendTagAttributeValueEscapingHTMLAttributeValue(response, urlAttribute, dataURL, NO);
|
|
}
|
|
|
|
-(id)initWithData:(NSData*)data
|
|
mimeType:(NSString*)type
|
|
key:(NSString*)key
|
|
{
|
|
if ((self=[super init]))
|
|
{
|
|
ASSIGN(_data,data);
|
|
NSDebugMLog(@"data=%@",_data);
|
|
ASSIGN(_mimeType,type);
|
|
NSDebugMLog(@"mimeType=%@",_mimeType);
|
|
NSDebugMLog(@"key=%@",key);
|
|
if (key)
|
|
{
|
|
ASSIGN(_key,key);
|
|
}
|
|
else
|
|
{
|
|
_temporaryKey=YES;
|
|
ASSIGN(_key,
|
|
[NSString stringUniqueIdWithLength:sizeof(NSTimeInterval)]);
|
|
};
|
|
NSDebugMLog(@"key=%@",_key);
|
|
};
|
|
return self;
|
|
};
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)dealloc
|
|
{
|
|
DESTROY(_data);
|
|
DESTROY(_mimeType);
|
|
DESTROY(_key);
|
|
[super dealloc];
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)appendDataURLToResponse:(GSWResponse*)aResponse
|
|
inContext:(GSWContext*)aContext
|
|
{
|
|
NSString* queryString=nil;
|
|
GSWDynamicURLString* url=nil;
|
|
queryString=[NSString stringWithFormat:@"%@=%@",GSWKey_Data[GSWebNamingConv],[self key]];
|
|
NSDebugMLog(@"queryString=%@",queryString);
|
|
url=[aContext urlWithRequestHandlerKey:GSWResourceRequestHandlerKey[GSWebNamingConv]
|
|
path:nil
|
|
queryString:queryString];
|
|
NSDebugMLog(@"url=%@",url);
|
|
GSWResponse_appendContentAsciiString(aResponse,(NSString*)url);
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)appendToResponse:(GSWResponse*)response
|
|
inContext:(GSWContext*)aContext
|
|
{
|
|
//OK
|
|
NSData* data=_data;
|
|
// GSWStartElement(aContext);
|
|
// GSWSaveAppendToResponseElementID(aContext);
|
|
NSDebugMLog(@"data=%@",data);
|
|
if (!data)
|
|
{
|
|
NSDebugMLog(@"key=%@",_key);
|
|
data=[NSData dataWithContentsOfFile:_key];
|
|
NSDebugMLog(@"data=%@",data);
|
|
}
|
|
else
|
|
[response setContent:data];
|
|
[response setHeader:GSWIntToNSString((int)[data length])
|
|
forKey:GSWHTTPHeader_ContentLength];
|
|
|
|
[response setHeader:_mimeType
|
|
forKey:GSWHTTPHeader_ContentType];
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(NSString*)description
|
|
{
|
|
return [NSString stringWithFormat:@"<%s %p>",
|
|
object_getClassName(self),
|
|
(void*)self];
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(BOOL)isTemporary
|
|
{
|
|
return _temporaryKey;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(NSData*)data
|
|
{
|
|
return _data;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(NSString*)type
|
|
{
|
|
return _mimeType;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(NSString*)key
|
|
{
|
|
return _key;
|
|
};
|
|
|
|
@end
|