mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-02-21 19:00:54 +00:00
o added -computeActionStringWithActionClassAssociation:
directActionNameAssociation:pathQueryDictionaryAssociation: otherPathQueryAssociations:inContext: git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@18731 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
19d18a8d45
commit
d1700d90a6
2 changed files with 237 additions and 18 deletions
|
@ -120,10 +120,38 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
||||||
directActionNameAssociation:(GSWAssociation*)directActionName
|
directActionNameAssociation:(GSWAssociation*)directActionName
|
||||||
otherPathQueryAssociations:(NSDictionary*)otherPathQueryAssociations
|
otherPathQueryAssociations:(NSDictionary*)otherPathQueryAssociations
|
||||||
inContext:(GSWContext*)context;
|
inContext:(GSWContext*)context;
|
||||||
|
-(NSString*)computeActionStringWithActionClassAssociation:(GSWAssociation*)actionClass
|
||||||
|
directActionNameAssociation:(GSWAssociation*)directActionName
|
||||||
|
pathQueryDictionaryAssociation:(GSWAssociation*)pathQueryDictionaryAssociation
|
||||||
|
otherPathQueryAssociations:(NSDictionary*)otherPathQueryAssociations
|
||||||
|
inContext:(GSWContext*)context;
|
||||||
-(NSDictionary*)computeQueryDictionaryWithActionClassAssociation:(GSWAssociation*)actionClass
|
-(NSDictionary*)computeQueryDictionaryWithActionClassAssociation:(GSWAssociation*)actionClass
|
||||||
directActionNameAssociation:(GSWAssociation*)directActionName
|
directActionNameAssociation:(GSWAssociation*)directActionName
|
||||||
queryDictionaryAssociation:(GSWAssociation*)queryDictionary
|
queryDictionaryAssociation:(GSWAssociation*)queryDictionary
|
||||||
otherQueryAssociations:(NSDictionary*)otherQueryAssociations
|
otherQueryAssociations:(NSDictionary*)otherQueryAssociations
|
||||||
inContext:(GSWContext*)context;
|
inContext:(GSWContext*)context;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
//====================================================================
|
||||||
|
@interface GSWHTMLDynamicElement (GSWHTMLDynamicElementCID)
|
||||||
|
|
||||||
|
-(NSString*)addCIDElement:(NSDictionary*)cidElement
|
||||||
|
forKey:(NSString*)cidKeyValue
|
||||||
|
forCIDStoreAssociation:(GSWAssociation*)cidStore
|
||||||
|
inContext:(GSWContext*)aContext;
|
||||||
|
|
||||||
|
-(NSString*)addURL:(NSString*)url
|
||||||
|
forCIDKeyAssociation:(GSWAssociation*)cidKey
|
||||||
|
CIDStoreAssociation:(GSWAssociation*)cidStore
|
||||||
|
inContext:(GSWContext*)aContext;
|
||||||
|
|
||||||
|
-(NSString*)addURLValuedElementData:(GSWURLValuedElementData*)data
|
||||||
|
forCIDKeyAssociation:(GSWAssociation*)cidKey
|
||||||
|
CIDStoreAssociation:(GSWAssociation*)cidStore
|
||||||
|
inContext:(GSWContext*)aContext;
|
||||||
|
-(NSString*)addPath:(NSString*)path
|
||||||
|
forCIDKeyAssociation:(GSWAssociation*)cidKey
|
||||||
|
CIDStoreAssociation:(GSWAssociation*)cidStore
|
||||||
|
inContext:(GSWContext*)aContext;
|
||||||
|
@end
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -765,11 +765,26 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
||||||
otherPathQueryAssociations:nil
|
otherPathQueryAssociations:nil
|
||||||
inContext:context];
|
inContext:context];
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
-(NSString*)computeActionStringWithActionClassAssociation:(GSWAssociation*)actionClass
|
-(NSString*)computeActionStringWithActionClassAssociation:(GSWAssociation*)actionClass
|
||||||
directActionNameAssociation:(GSWAssociation*)directActionName
|
directActionNameAssociation:(GSWAssociation*)directActionName
|
||||||
otherPathQueryAssociations:(NSDictionary*)otherPathQueryAssociations
|
otherPathQueryAssociations:(NSDictionary*)otherPathQueryAssociations
|
||||||
inContext:(GSWContext*)context
|
inContext:(GSWContext*)context
|
||||||
|
{
|
||||||
|
return [self computeActionStringWithActionClassAssociation:actionClass
|
||||||
|
directActionNameAssociation:directActionName
|
||||||
|
pathQueryDictionaryAssociation:nil
|
||||||
|
otherPathQueryAssociations:nil
|
||||||
|
inContext:context];
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
-(NSString*)computeActionStringWithActionClassAssociation:(GSWAssociation*)actionClass
|
||||||
|
directActionNameAssociation:(GSWAssociation*)directActionName
|
||||||
|
pathQueryDictionaryAssociation:(GSWAssociation*)pathQueryDictionaryAssociation
|
||||||
|
otherPathQueryAssociations:(NSDictionary*)otherPathQueryAssociations
|
||||||
|
inContext:(GSWContext*)context
|
||||||
{
|
{
|
||||||
//OK
|
//OK
|
||||||
GSWComponent* component=nil;
|
GSWComponent* component=nil;
|
||||||
|
@ -801,26 +816,63 @@ attributeAssociations:(NSDictionary*)attributeAssociations
|
||||||
directActionName);
|
directActionName);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (tmpDirectActionString && [otherPathQueryAssociations count]>0)
|
if (tmpDirectActionString)
|
||||||
{
|
{
|
||||||
// We sort keys so URL are always the same for same parameters
|
NSDictionary* pathQueryDictionary=nil;
|
||||||
NSArray* keys=[[otherPathQueryAssociations allKeys]sortedArrayUsingSelector:@selector(compare:)];
|
if (pathQueryDictionaryAssociation)
|
||||||
int count=[keys count];
|
|
||||||
int i=0;
|
|
||||||
NSDebugMLLog(@"gswdync",@"otherPathQueryAssociations=%@",otherPathQueryAssociations);
|
|
||||||
for(i=0;i<count;i++)
|
|
||||||
{
|
{
|
||||||
id associationKey = [keys objectAtIndex:i];
|
NSDebugMLLog(@"gswdync",@"pathQueryDictionaryAssociation=%@",
|
||||||
id association = [otherPathQueryAssociations valueForKey:associationKey];
|
pathQueryDictionaryAssociation);
|
||||||
id associationValue=[association valueInComponent:component];
|
|
||||||
NSDebugMLLog(@"gswdync",@"associationKey=%@",associationKey);
|
pathQueryDictionary=[pathQueryDictionaryAssociation
|
||||||
NSDebugMLLog(@"gswdync",@"association=%@",association);
|
valueInComponent:component];
|
||||||
NSDebugMLLog(@"gswdync",@"associationValue=%@",associationValue);
|
|
||||||
if (!associationValue)
|
NSDebugMLLog(@"gswdync",@"pathQueryDictionary=%@",
|
||||||
associationValue=[NSString string];
|
pathQueryDictionary);
|
||||||
tmpDirectActionString=[tmpDirectActionString stringByAppendingFormat:@"/%@=%@",
|
};
|
||||||
associationKey,
|
if ([pathQueryDictionary count]>0 || [otherPathQueryAssociations count]>0)
|
||||||
associationValue];
|
{
|
||||||
|
NSMutableDictionary* pathKV=nil;
|
||||||
|
if ([otherPathQueryAssociations count]>0)
|
||||||
|
{
|
||||||
|
NSEnumerator* enumerator = [otherPathQueryAssociations keyEnumerator];
|
||||||
|
id key=nil;
|
||||||
|
pathKV=(NSMutableDictionary*)[NSMutableDictionary dictionary];
|
||||||
|
while ((key = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
id association = [otherPathQueryAssociations valueForKey:key];
|
||||||
|
id associationValue=[association valueInComponent:component];
|
||||||
|
NSDebugMLLog(@"gswdync",@"key=%@",key);
|
||||||
|
NSDebugMLLog(@"gswdync",@"association=%@",association);
|
||||||
|
NSDebugMLLog(@"gswdync",@"associationValue=%@",associationValue);
|
||||||
|
if (!associationValue)
|
||||||
|
associationValue=[NSString string];
|
||||||
|
[pathKV setObject:associationValue
|
||||||
|
forKey:key];
|
||||||
|
};
|
||||||
|
if ([pathQueryDictionary count]>0)
|
||||||
|
[pathKV addEntriesFromDictionary:pathQueryDictionary];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pathKV=(NSMutableDictionary*)pathQueryDictionary;
|
||||||
|
|
||||||
|
NSDebugMLLog(@"gswdync",@"pathKV=%@",pathKV);
|
||||||
|
|
||||||
|
// We sort keys so URL are always the same for same parameters
|
||||||
|
NSArray* keys=[[pathKV allKeys]sortedArrayUsingSelector:@selector(compare:)];
|
||||||
|
int count=[keys count];
|
||||||
|
int i=0;
|
||||||
|
NSDebugMLLog(@"gswdync",@"pathKV=%@",pathKV);
|
||||||
|
for(i=0;i<count;i++)
|
||||||
|
{
|
||||||
|
id key = [keys objectAtIndex:i];
|
||||||
|
id value = [pathKV valueForKey:key];
|
||||||
|
NSDebugMLLog(@"gswdync",@"key=%@",key);
|
||||||
|
NSDebugMLLog(@"gswdync",@"value=%@",value);
|
||||||
|
tmpDirectActionString=[tmpDirectActionString stringByAppendingFormat:@"/%@=%@",
|
||||||
|
key,
|
||||||
|
value];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -909,3 +961,142 @@ in GSWHyperlink, it was
|
||||||
return finalQueryDictionary;
|
return finalQueryDictionary;
|
||||||
};
|
};
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
//====================================================================
|
||||||
|
@implementation GSWHTMLDynamicElement (GSWHTMLDynamicElementCID)
|
||||||
|
|
||||||
|
|
||||||
|
-(NSString*)addCIDElement:(NSDictionary*)cidElement
|
||||||
|
forKey:(NSString*)cidKeyValue
|
||||||
|
forCIDStoreAssociation:(GSWAssociation*)cidStore
|
||||||
|
inContext:(GSWContext*)aContext
|
||||||
|
{
|
||||||
|
NSString* newURL=nil;
|
||||||
|
LOGObjectFnStart();
|
||||||
|
NSDebugMLog(@"cidElement=%@",cidElement);
|
||||||
|
NSDebugMLog(@"cidKeyValue=%@",cidKeyValue);
|
||||||
|
NSDebugMLog(@"cidStore=%@",cidStore);
|
||||||
|
if (cidElement && cidStore)
|
||||||
|
{
|
||||||
|
id cidObject=nil;
|
||||||
|
GSWComponent* component=[aContext component];
|
||||||
|
cidObject=[cidStore valueInComponent:component];
|
||||||
|
NSDebugMLog(@"cidObject=%@",cidObject);
|
||||||
|
/* if (!cidObject)
|
||||||
|
{
|
||||||
|
cidObject=(NSMutableDictionary*)[NSMutableDictionary dictionary];
|
||||||
|
[_cidStore setValue:cidObject
|
||||||
|
inComponent:component];
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
if (cidObject)
|
||||||
|
{
|
||||||
|
if (![cidObject valueForKey:cidKeyValue])
|
||||||
|
[cidObject takeValue:cidElement
|
||||||
|
forKey:cidKeyValue];
|
||||||
|
newURL=[NSString stringWithFormat:@"cid:%@",
|
||||||
|
cidKeyValue];
|
||||||
|
};
|
||||||
|
NSDebugMLog(@"newURL=%@",newURL);
|
||||||
|
};
|
||||||
|
LOGObjectFnStop();
|
||||||
|
return newURL;
|
||||||
|
};
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
-(NSString*)addURL:(NSString*)url
|
||||||
|
forCIDKeyAssociation:(GSWAssociation*)cidKey
|
||||||
|
CIDStoreAssociation:(GSWAssociation*)cidStore
|
||||||
|
inContext:(GSWContext*)aContext
|
||||||
|
{
|
||||||
|
NSString* newURL=nil;
|
||||||
|
LOGObjectFnStart();
|
||||||
|
if (url && cidStore)
|
||||||
|
{
|
||||||
|
NSString* cidKeyValue=nil;
|
||||||
|
GSWComponent* component=[aContext component];
|
||||||
|
cidKeyValue=(NSString*)[cidKey valueInComponent:component];
|
||||||
|
NSDebugMLLog(@"gswdync",@"cidKeyValue=%@",cidKeyValue);
|
||||||
|
if (!cidKeyValue)
|
||||||
|
{
|
||||||
|
// We calculate cidKeyValue by computing md5 on url
|
||||||
|
// so there will be no duplicate elements with different keys
|
||||||
|
NSData* data = [url dataUsingEncoding: NSISOLatin1StringEncoding];
|
||||||
|
cidKeyValue=[[data md5Digest] hexadecimalRepresentation];
|
||||||
|
};
|
||||||
|
newURL=[self addCIDElement:[NSDictionary dictionaryWithObject:url
|
||||||
|
forKey:@"url"]
|
||||||
|
forKey:cidKeyValue
|
||||||
|
forCIDStoreAssociation:cidStore
|
||||||
|
inContext:aContext];
|
||||||
|
}
|
||||||
|
LOGObjectFnStop();
|
||||||
|
return newURL;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
-(NSString*)addURLValuedElementData:(GSWURLValuedElementData*)data
|
||||||
|
forCIDKeyAssociation:(GSWAssociation*)cidKey
|
||||||
|
CIDStoreAssociation:(GSWAssociation*)cidStore
|
||||||
|
inContext:(GSWContext*)aContext
|
||||||
|
{
|
||||||
|
NSString* newURL=nil;
|
||||||
|
LOGObjectFnStart();
|
||||||
|
if (data && cidStore)
|
||||||
|
{
|
||||||
|
NSString* cidKeyValue=nil;
|
||||||
|
GSWComponent* component=[aContext component];
|
||||||
|
cidKeyValue=(NSString*)[cidKey valueInComponent:component];
|
||||||
|
NSDebugMLLog(@"gswdync",@"cidKeyValue=%@",cidKeyValue);
|
||||||
|
if (!cidKeyValue)
|
||||||
|
{
|
||||||
|
// We calculate cidKeyValue by computing md5 on path
|
||||||
|
// so there will be no duplicate elements with different keys
|
||||||
|
//NSString* cidKeyValue=[[data md5Digest] hexadecimalRepresentation];
|
||||||
|
cidKeyValue=[data key];
|
||||||
|
};
|
||||||
|
newURL=[self addCIDElement:[NSDictionary dictionaryWithObject:data
|
||||||
|
forKey:@"data"]
|
||||||
|
forKey:cidKeyValue
|
||||||
|
forCIDStoreAssociation:cidStore
|
||||||
|
inContext:aContext];
|
||||||
|
}
|
||||||
|
LOGObjectFnStop();
|
||||||
|
return newURL;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
-(NSString*)addPath:(NSString*)path
|
||||||
|
forCIDKeyAssociation:(GSWAssociation*)cidKey
|
||||||
|
CIDStoreAssociation:(GSWAssociation*)cidStore
|
||||||
|
inContext:(GSWContext*)aContext
|
||||||
|
{
|
||||||
|
NSString* newURL=nil;
|
||||||
|
LOGObjectFnStart();
|
||||||
|
if (path && cidStore)
|
||||||
|
{
|
||||||
|
NSString* cidKeyValue=nil;
|
||||||
|
GSWComponent* component=[aContext component];
|
||||||
|
cidKeyValue=(NSString*)[cidKey valueInComponent:component];
|
||||||
|
NSDebugMLLog(@"gswdync",@"cidKeyValue=%@",cidKeyValue);
|
||||||
|
if (!cidKeyValue)
|
||||||
|
{
|
||||||
|
// We calculate cidKeyValue by computing md5 on path
|
||||||
|
// so there will be no duplicate elements with different keys
|
||||||
|
NSData* data = [path dataUsingEncoding: NSISOLatin1StringEncoding];
|
||||||
|
cidKeyValue=[[data md5Digest] hexadecimalRepresentation];
|
||||||
|
};
|
||||||
|
|
||||||
|
newURL=[self addCIDElement:[NSDictionary dictionaryWithObject:path
|
||||||
|
forKey:@"filePath"]
|
||||||
|
forKey:cidKeyValue
|
||||||
|
forCIDStoreAssociation:cidStore
|
||||||
|
inContext:aContext];
|
||||||
|
}
|
||||||
|
LOGObjectFnStop();
|
||||||
|
return newURL;
|
||||||
|
};
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
Loading…
Reference in a new issue