/*
- Copyright (C) 2000-2004 SKYRIX Software AG
+ Copyright (C) 2000-2005 SKYRIX Software AG
- This file is part of OpenGroupware.org.
+ This file is part of SOPE.
- OGo is free software; you can redistribute it and/or modify it under
+ SOPE is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
- OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ SOPE 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 Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with OGo; see the file COPYING. If not, write to the
+ License along with SOPE; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
@implementation WOContext
+ (int)version {
- 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;
+ return 8;
+}
+
+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 {
if ((self = [super init])) {
unsigned char buf[24];
- self->qpJoin = @"&";
+ self->qpJoin = @"&";
sprintf(buf, "%03x%08x%08x", ++contextCount, (int)time(NULL), (int)self);
self->ctxId = [[NSString alloc] initWithCString:buf];
+ /* per default close tags in XML style */
+ self->wcFlags.xmlStyleEmptyElements = 1;
+
self->elementID = [[WOElementID alloc] init];
self->awakeComponents = [[NSMutableSet alloc] initWithCapacity:64];
}
- (BOOL)savePageRequired {
- return self->savePageRequired;
+ return self->wcFlags.savePageRequired ? YES : NO;
}
/* cursors */
/* forms */
- (void)setInForm:(BOOL)_form {
- self->inForm = _form;
+ self->wcFlags.inForm = _form ? 1 : 0;
}
- (BOOL)isInForm {
- return self->inForm;
+ return self->wcFlags.inForm ? YES : NO;
}
- (void)addActiveFormElement:(WOElement *)_formElement {
/* described in Apple TIL article 70101 */
}
+- (void)setQueryPathSeparator:(NSString *)_sp {
+ ASSIGNCOPY(self->qpJoin, _sp);
+}
+- (NSString *)queryPathSeparator {
+ return self->qpJoin;
+}
+
+- (void)setGenerateXMLStyleEmptyElements:(BOOL)_flag {
+ self->wcFlags.xmlStyleEmptyElements = _flag ? 1 : 0;
+}
+- (BOOL)generateXMLStyleEmptyElements {
+ return self->wcFlags.xmlStyleEmptyElements ? YES : NO;
+}
+
- (NSString *)queryStringFromDictionary:(NSDictionary *)_queryDict {
NSEnumerator *keys;
NSString *key;
NSMutableString *qs;
NSString *p;
- self->savePageRequired = YES;
+ self->wcFlags.savePageRequired = 1;
qs = [MutableStrClass stringWithCapacity:64];
[qs appendString:WORequestValueSenderID];
static NSMutableString *url = nil; // THREAD
static IMP addStr = NULL;
NSString *s;
-
- self->savePageRequired = YES;
+
+ self->wcFlags.savePageRequired = 1;
if (url == nil) {
url = [[MutableStrClass alloc] initWithCapacity:256];
addStr = [url methodForSelector:@selector(appendString:)];
#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)