/*
- 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.
*/
NGObjWeb_DECLARE NSString *WORequestValueSessionID = @"wosid";
NGObjWeb_DECLARE NSString *WONoSelectionString = @"WONoSelectionString";
+@interface WOCoreApplication(Resources)
++ (NSString *)findNGObjWebResource:(NSString *)_name ofType:(NSString *)_ext;
+@end
+
@implementation WORequest
static BOOL debugOn = NO;
return [super version] + 2 /* v7 */;
}
-+ (NSString *)lookupLanguagesPlist {
- NSString *apath;
-#if !COMPILE_AS_FRAMEWORK
- NSFileManager *fm = [NSFileManager defaultManager];
- NSDictionary *env;
- NSString *relPath;
-#else
- NSBundle *bundle;
-#endif
-
-#if COMPILE_AS_FRAMEWORK
- bundle = [NSBundle bundleForClass:self];
- apath = [bundle pathForResource:@"Languages" ofType:@"plist"];
-#else
- env = [[NSProcessInfo processInfo] environment];
-
- /*
- TODO: the following is a dirty hack because GNUstep people decided
- to change the directory structure. SIGH!
- */
-#if APPLE_FOUNDATION_LIBRARY || NeXT_Foundation_LIBRARY || GNUSTEP_BASE_LIBRARY
- relPath = @"Library/Libraries";
-#else
- relPath = @"Libraries";
-#endif
- relPath = [relPath stringByAppendingPathComponent:@"Resources"];
- relPath = [relPath stringByAppendingPathComponent:@"NGObjWeb"];
- relPath = [relPath stringByAppendingPathComponent:@"Languages.plist"];
-
- apath = [env objectForKey:@"GNUSTEP_USER_ROOT"];
- apath = [apath stringByAppendingPathComponent:relPath];
- if (![fm fileExistsAtPath:apath]) {
- apath = [env objectForKey:@"GNUSTEP_LOCAL_ROOT"];
- apath = [apath stringByAppendingPathComponent:relPath];
- }
- if (![fm fileExistsAtPath:apath]) {
- apath = [env objectForKey:@"GNUSTEP_SYSTEM_ROOT"];
- apath = [apath stringByAppendingPathComponent:relPath];
- }
- if (![fm fileExistsAtPath:apath]) {
- apath = relPath;
- }
- if (![fm fileExistsAtPath:apath]) {
- NSLog(@"ERROR: cannot find Languages.plist resource "
- @"of NGObjWeb library !");
- }
-#endif
- return apath;
-}
-
+ (void)initialize {
static BOOL isInitialized = NO;
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
/* load language mappings */
- apath = [self lookupLanguagesPlist];
- langMap = [NSDictionary dictionaryWithContentsOfFile:apath];
+ apath = [WOApplication findNGObjWebResource:@"Languages" ofType:@"plist"];
+ if (apath == nil) {
+ [self errorWithFormat:@"cannot find Languages.plist resource "
+ @"of NGObjWeb library !"];
+ langMap = nil;
+ }
+ else
+ langMap = [NSDictionary dictionaryWithContentsOfFile:apath];
- if (langMap) {
+ if (langMap != nil) {
NSDictionary *defs;
defs = [NSDictionary dictionaryWithObject:langMap
[ud registerDefaults:defs];
}
else
- NSLog(@"WARNING: did not register browser language mappings: %@", apath);
+ [self warnWithFormat:
+ @"did not register browser language mappings: %@", apath];
}
/* parse URI */
}
- (NGHashMap *)_getFormParameters {
- if (self->formContent)
+ if (self->formContent != nil)
return self->formContent;
- if (self->request == nil) {
+ if (self->request != nil) {
+ self->formContent = [[self->request formParameters] retain];
+ return self->formContent;
+ }
+
+ {
/*
TODO: add parsing of form values
if ((ctype = [self headerForKey:@"content-type"]) != nil) {
isFormContent = [ctype hasPrefix:@"application/x-www-form-urlencoded"];
if (!isFormContent)
- isMultiPartContent = [ctype hasPrefix:@"multipart/form-data"];
+ isMultiPartContent = [ctype hasPrefix:@"multipart/form-data"];
}
if (query != nil || isFormContent || isMultiPartContent) {
/* parse query string */
if (query)
- [self _parseQueryParameters:query intoMap:self->formContent];
+ [self _parseQueryParameters:query intoMap:self->formContent];
/* parse content (if form content) */
if (isFormContent) {
- [self _parseQueryParameters:[self contentAsString]
+ [self _parseQueryParameters:[self contentAsString]
intoMap:self->formContent];
}
else if (isMultiPartContent) {
- [self logWithFormat:
- @"ERROR: missing NGHttpRequest, cannot parse multipart"];
+ [self errorWithFormat:@"missing NGHttpRequest, cannot parse multipart"];
}
[pool release];
else
self->formContent = [[NGHashMap alloc] init];
}
- else
- self->formContent = [[self->request formParameters] retain];
return self->formContent;
}
if ([paras isKindOfClass:[NSDictionary class]])
return paras;
- [self logWithFormat:
- @"ERROR(%s): don't know how to deal with form object: %@", paras];
+ [self errorWithFormat:@"(%s): don't know how to deal with form object: %@",
+ paras];
return nil;
}
langMap = [[ud dictionaryForKey:@"WOBrowserLanguageMappings"] copy];
if (langMap == nil) {
- [self debugWithFormat:
- @"WARNING: did not find browser language mappings!"];
+ [self warnWithFormat:@"did not find browser language mappings!"];
}
}