/* lookup languages */
- ctx = [_component context];
- languages = [ctx hasSession]
- ? [[ctx session] languages]
- : [[ctx request] browserLanguages];
+ ctx = [_component context];
+ languages = [ctx resourceLookupLanguages];
/* find resource manager */
if ((ctx = [_component context]) == nil)
ctx = [[WOApplication application] context];
rq = [ctx request];
- langs = [ctx hasSession]
- ? [[ctx session] languages]
- : [[ctx request] browserLanguages];
+ langs = [ctx resourceLookupLanguages];
if (doDebug) {
[self debugWithFormat:@" languages: %@",
2005-01-04 Marcus Mueller <znek@mulle-kybernetik.com>
+ * v4.5.106
+
+ * Defaults.plist: added new default "WOContextClass".
+
+ * WOContext.[hm]: Factory method +contextWithRequest: observes new user
+ default "WOContextClass" to chose proper class for new contexts.
+ New method -resourceLookupLanguages, aggregates the
+ current lookup strategy in one place. Ideal place for overriding the
+ lookup behaviour in conjunction with new WOContextClass default.
+
+ * WOApplication.m, WOComponentDefinition.m, WOStats.m, WOComponent.m,
+ DynamicElements/{_WOComplexHyperlink.m, WOImageButton.m,
+ _WOConstResourceImage.m, WOJavaScript.m, WOResourceURL.m,
+ WOEmbeddedObject.m, WOBody.m}, SoObjects/{SoPageInvocation.m,
+ SoProductResourceManager.m},
+ Associations/{WOResourceURLAssociation.m, WOLabelAssociation.m}:
+ use new -resourceLookupLanguages API.
+
* v4.5.105
* NGObjWeb.xcode: removed target "SoProducts" from "all". By using a
WOComponentRequestHandlerKey = "wo";
WOCompoundElementPool = NO;
WOContactSNS = NO;
+ WOContextClass = WOContext;
WOCoreOnApplicationException = NO;
WOCoreOnAwakeComponentInCtxDealloc = NO;
WOCoreOnHTTPAdaptorException = NO;
WOResponse_AddCString(_response, " background=\"");
- languages = [_ctx hasSession]
- ? [[_ctx session] languages]
- : [[_ctx request] browserLanguages];
+ languages = [_ctx resourceLookupLanguages];
if ((rm = [[_ctx component] resourceManager]) == nil)
rm = [[_ctx application] resourceManager];
else
frameworkName = [[_ctx component] frameworkName];
- languages = [_ctx hasSession]
- ? [[_ctx session] languages]
- : [[_ctx request] browserLanguages];
- uFi = [rm urlForResourceNamed:uFi
- inFramework:frameworkName
- languages:languages
- request:[_ctx request]];
+ languages = [_ctx resourceLookupLanguages];
+ uFi = [rm urlForResourceNamed:uFi
+ inFramework:frameworkName
+ languages:languages
+ request:[_ctx request]];
if (uFi == nil) {
NSLog(@"%@: did not find resource '%@'", sComponent,
[self->filename stringValueInComponent:sComponent]);
if ((rm = [[_ctx component] resourceManager]) == nil)
rm = [[_ctx application] resourceManager];
- langs = [_ctx hasSession]
- ? [[_ctx session] languages]
- : [[_ctx request] browserLanguages];
+ langs = [_ctx resourceLookupLanguages];
/* If 'framework' binding is not set, use parent component's framework */
if (self->framework){
if ((rm = [[_ctx component] resourceManager]) == nil)
rm = [[_ctx application] resourceManager];
- languages = [_ctx hasSession]
- ? [[_ctx session] languages]
- : [[_ctx request] browserLanguages];
- s = [rm pathForResourceNamed:s inFramework:nil languages:languages];
- if (s) s = [[NSString alloc] initWithContentsOfFile:s];
+ languages = [_ctx resourceLookupLanguages];
+ s = [rm pathForResourceNamed:s inFramework:nil languages:languages];
+ if (s) s = [[NSString alloc] initWithContentsOfFile:s];
}
/* append to response */
else
frameworkName = [sComponent frameworkName];
- languages = [_ctx hasSession]
- ? [[_ctx session] languages]
- : [[_ctx request] browserLanguages];
- uFi = [rm urlForResourceNamed:uFi
- inFramework:frameworkName
- languages:languages
- request:[_ctx request]];
+ languages = [_ctx resourceLookupLanguages];
+ uFi = [rm urlForResourceNamed:uFi
+ inFramework:frameworkName
+ languages:languages
+ request:[_ctx request]];
if (uFi == nil) {
NSLog(@"%@: did not find resource '%@'", sComponent,
[self->filename stringValueInComponent:sComponent]);
if (!((uFi != nil) || (uUri != nil)))
return;
- languages = [_ctx hasSession]
- ? [[_ctx session] languages]
- : [[_ctx request] browserLanguages];
+ languages = [_ctx resourceLookupLanguages];
WOResponse_AddCString(_resp, "<img src=\"");
if ((rm = [[_ctx component] resourceManager]) == nil)
rm = [[_ctx application] resourceManager];
- languages = [_ctx hasSession]
- ? [[_ctx session] languages]
- : [[_ctx request] browserLanguages];
+ languages = [_ctx resourceLookupLanguages];
if (debugOn) {
[self debugWithFormat:@"WOImage: filename '%@'\n rm %@\n languages %@",
*/
@class NSString, NSMutableDictionary, NSMutableArray, NSMutableSet;
-@class NSDictionary, NSURL;
+@class NSArray, NSDictionary, NSURL;
@class WOApplication, WOSession, WOComponent, WORequest, WOResponse;
@class WOElementID;
@end
+@interface WOContext(SOPEAdditions)
+
+/* languages for resource lookup (non-WO) */
+
+- (NSArray *)resourceLookupLanguages;
+
+@end
+
#endif /* __NGObjWeb_WOContext_H__ */
/* determine language */
- languages = [_ctx hasSession]
- ? [(WOSession *)[_ctx session] languages]
- : [[(id <WOPageGenerationContext>)_ctx request] browserLanguages];
+ languages = [_ctx resourceLookupLanguages];
/* instantiate */
/* ask resource-manager (self) for path */
- languages = [_ctx hasSession]
- ? [(WOSession *)[_ctx session] languages]
- : [[(id <WOPageGenerationContext>)_ctx request] browserLanguages];
+ languages = [_ctx resourceLookupLanguages];
p = [self pathForResourceNamed:_key
inFramework:[b bundlePath]
# version file
-SUBMINOR_VERSION:=105
+SUBMINOR_VERSION:=106
# v4.5.91 requires libNGExtensions v4.5.134
# v4.5.84 requires libNGExtensions v4.5.127
start = [self memoryStatistics];
#endif
- pool = [[NSAutoreleasePool alloc] init];
+ pool = [[NSAutoreleasePool alloc] init];
- languages = [_ctx hasSession]
- ? [(WOSession *)[_ctx session] languages]
- : [[_ctx request] browserLanguages];
+ languages = [_ctx resourceLookupLanguages];
if ((rm = [[_ctx component] resourceManager]) == nil)
rm = [self resourceManager];
- page = [rm pageWithName:(_name != nil ? _name : @"Main")
- languages:languages];
+ page = [rm pageWithName:(_name != nil ? _name : @"Main")
+ languages:languages];
[page ensureAwakeInContext:_ctx];
page = [page retain];
NSArray *languages = nil;
#if 0 // the component might not yet be awake !
- languages = [self hasSession]
- ? [[self session] languages]
- : [[[self context] request] browserLanguages];
+ languages = [[self context] resourceLookupLanguages];
#endif
return [[self resourceManager]
}
- (WOComponent *)pageWithName:(NSString *)_name {
- NSArray *languages = nil;
+ NSArray *languages;
WOResourceManager *rm;
WOComponent *component;
- languages = [self hasSession]
- ? [(WOSession *)[self session] languages]
- : [[[self context] request] browserLanguages];
-
- rm = [self resourceManager];
-
+ languages = [[self context] resourceLookupLanguages];
+ rm = [self resourceManager];
+
/*
Note: this API is somewhat broken since the component expects the
-initWithContext: message for initialization yet we pass no
NSArray *langs;
IS_DEPRECATED;
- langs = [self hasSession]
- ? [(WOSession *)[self session] languages]
- : [[[self context] request] browserLanguages];
+ langs = [[self context] resourceLookupLanguages];
return [[[self application]
resourceManager]
return nil;
}
- languages = [self hasSession]
- ? [(WOSession *)[self session] languages]
- : [[[self context] request] browserLanguages];
-
- tmpl = [resourceManager templateWithName:_name languages:languages];
+ languages = [[self context] resourceLookupLanguages];
+ tmpl = [resourceManager templateWithName:_name languages:languages];
+
if (debugTemplates) [self debugWithFormat:@"found template: %@", tmpl];
return tmpl;
}
[self setName:_cname];
if ((self = [self initWithContext:_ctx])) {
NSMutableDictionary *childComponents;
- NSArray *langs;
-
- langs = [self hasSession]
- ? [[self session] languages]
- : [[_ctx request] browserLanguages];
+ NSArray *langs;
+
+ langs = [[self context] resourceLookupLanguages];
childComponents = [self instantiateChildComponentsInTemplate:_template
- languages:langs];
+ languages:langs];
[self setSubComponents:childComponents];
[self setTemplate:_template];
}
return 7;
}
-static Class MutableStrClass = Nil;
-static int contextCount = 0;
-static int logComponents = -1;
-static int relativeURLs = -1;
-static BOOL debugOn = NO;
-static int debugCursor = -1;
-static BOOL debugComponentAwake = NO;
-static BOOL testNSURLs = NO;
-static BOOL newCURLStyle = NO;
+static Class WOContextClass = Nil;
+static Class MutableStrClass = Nil;
+static int contextCount = 0;
+static int logComponents = -1;
+static int relativeURLs = -1;
+static BOOL debugOn = NO;
+static int debugCursor = -1;
+static BOOL debugComponentAwake = NO;
+static BOOL testNSURLs = NO;
+static BOOL newCURLStyle = NO;
static NSString *WOApplicationSuffix = nil;
+ (void)initialize {
- NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
- static BOOL didInitialize = NO;
- if (didInitialize) return;
+ static BOOL didInit = NO;
+ NSUserDefaults *ud;
+ NSString *cn;
+
+ if (didInit) return;
+
+ didInit = YES;
+
+ ud = [NSUserDefaults standardUserDefaults];
if (WOAppClass == Nil)
WOAppClass = [WOApplication class];
if (MutableStrClass == Nil)
MutableStrClass = [NSMutableString class];
- didInitialize = YES;
-
+ cn = [ud stringForKey:@"WOContextClass"];
+ WOContextClass = NSClassFromString(cn);
+ NSAssert1(WOContextClass != Nil,
+ @"Couldn't instantiate WOContextClass (%@)!", cn);
+
logComponents = [[ud objectForKey:@"WOLogComponents"] boolValue] ? 1 : 0;
relativeURLs = [[ud objectForKey:@"WOUseRelativeURLs"] boolValue]? 1 : 0;
debugCursor = [ud boolForKey:@"WODebugCursor"] ? 1 : 0;
WOApplicationSuffix = [[ud stringForKey:@"WOApplicationSuffix"] copy];
}
-+ (id)contextWithRequest:(WORequest *)_request {
- return [[(WOContext *)[self alloc] initWithRequest:_request] autorelease];
++ (id)contextWithRequest:(WORequest *)_r {
+ return [[(WOContext *)[WOContextClass alloc] initWithRequest:_r] autorelease];
}
- (id)initWithRequest:(WORequest *)_request {
#endif
}
+/* languages for resource lookup (non-WO) */
+
+- (NSArray *)resourceLookupLanguages {
+ return [self hasSession] ? [[self session] languages]
+ : [[self request] browserLanguages];
+}
+
+
/* DeprecatedMethodsInWO4 */
- (WOApplication *)application {
return url;
}
-@end /* WOContext(DeprecatedMethodsInWO4) */
-
+@end /* WOContext */
@implementation WOComponent(Cursors)
#include <NGObjWeb/WODirectAction.h>
#include <NGObjWeb/WOApplication.h>
#include <NGObjWeb/WOResourceManager.h>
+#include <NGObjWeb/WOContext.h>
#include <NGObjWeb/WORequest.h>
#include <NGObjWeb/WOResponse.h>
#include <NGObjWeb/WOSession.h>
xslPath = [[NSUserDefaults standardUserDefaults]
stringForKey:@"WOStatsStylesheetName"];
- languages = [self existingSession] != nil
- ? [[self session] languages]
- : [[self request] browserLanguages];
- xslPath = [[app resourceManager] urlForResourceNamed:xslPath
- inFramework:nil
- languages:languages
- request:[self request]];
+ languages = [[self context] resourceLookupLanguages];
+ xslPath = [[app resourceManager] urlForResourceNamed:xslPath
+ inFramework:nil
+ languages:languages
+ request:[self request]];
if ([xslPath hasPrefix:@"/missingresource"])
xslPath = nil;