/*
- 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.
*/
return debugOn;
}
- (NSString *)loggingPrefix {
- unsigned char buf[32];
+ char buf[32];
sprintf(buf, "[wo-rm-0x%08X]", (unsigned)self);
return [NSString stringWithCString:buf];
}
}
- (NSString *)resourcesPathForFramework:(NSString *)_fw {
- if (_fw == nil)
+ if (_fw == nil || (_fw == rapidTurnAroundPath))
return [self resourcesPath];
#if RSRCDIR_CONTENTS
/* string tables */
-- (NSString *)stringForKey:(NSString *)_key
- inTableNamed:(NSString *)_tableName
- withDefaultValue:(NSString *)_defaultValue
+- (id)stringTableWithName:(NSString *)_tableName
inFramework:(NSString *)_framework
- languages:(NSArray *)_languages;
+ languages:(NSArray *)_languages
{
+ /* side effect: tables are cached (currently not affected by default!) */
NSFileManager *fm;
_WOStringTable *table = nil;
NSString *path = nil;
fm = [self fileManager];
if (_tableName == nil)
- _tableName = @"default";
+ _tableName = @"Localizable";
/* take a look whether a matching table is already loaded */
path = [self pathForResourceNamed:path inFramework:_framework
languages:_languages];
- if (path != nil) {
- if ((table = NSMapGet(self->stringTables, path)) == NULL) {
- if ([fm fileExistsAtPath:path]) {
- table = [_WOStringTable allocWithZone:[self zone]]; /* for gcc */
- table = [table initWithPath:path];
- NSMapInsert(self->stringTables, path, table);
- [table release];
- }
+ if (path == nil)
+ return nil;
+
+ if ((table = NSMapGet(self->stringTables, path)) == NULL) {
+ if ([fm fileExistsAtPath:path]) {
+ table = [_WOStringTable allocWithZone:[self zone]]; /* for gcc */
+ table = [table initWithPath:path];
+ NSMapInsert(self->stringTables, path, table);
+ [table release];
}
- if (table != nil)
- return [table stringForKey:_key withDefaultValue:_defaultValue];
}
- /* didn't found table in cache */
+ return table;
+}
+
+- (NSString *)stringForKey:(NSString *)_key
+ inTableNamed:(NSString *)_tableName
+ withDefaultValue:(NSString *)_defaultValue
+ inFramework:(NSString *)_framework
+ languages:(NSArray *)_languages
+{
+ _WOStringTable *table = nil;
- return _defaultValue;
+ table = [self stringTableWithName:_tableName inFramework:_framework
+ languages:_languages];
+
+ return (table != nil)
+ ? [table stringForKey:_key withDefaultValue:_defaultValue]
+ : _defaultValue;
}
- (NSString *)stringForKey:(NSString *)_key
_nameOrURL, _framework];
}
+ /* look for .wox component */
- /* look for .wox component */
+ path = [self pathForResourceNamed:
+ [self resourceNameForComponentNamed:*name_]
+ inFramework:_framework
+ languages:_languages];
- path = [self pathForResourceNamed:
- [self resourceNameForComponentNamed:*name_]
- inFramework:_framework
- languages:_languages];
+ if (debugComponentLookup)
+ [self logWithFormat:@" .wox path: '%@'", path];
- if (debugComponentLookup)
- [self logWithFormat:@" path: '%@'", path];
-
- /* look for .wo component */
+ /* look for .wo component */
- if ([path length] == 0) {
- path = [self pathToComponentNamed:*name_
- inFramework:_framework
- languages:_languages];
- if (debugComponentLookup)
- [self logWithFormat:@" path: '%@'", path];
- }
+ if ([path length] == 0) {
+ path = [self pathToComponentNamed:*name_
+ inFramework:_framework
+ languages:_languages];
+ if (debugComponentLookup)
+ [self logWithFormat:@" .wo path: '%@'", path];
+ }
- /* make URL from path */
+ /* make URL from path */
- *url_ = ([path length] > 0)
- ? [[[UrlClass alloc] initFileURLWithPath:path] autorelease]
- : nil;
+ *url_ = ([path length] > 0)
+ ? [[[UrlClass alloc] initFileURLWithPath:path] autorelease]
+ : nil;
}
- (WOComponentDefinition *)definitionForFileURL:(NSURL *)componentURL
/* lookup component path */
+ // TODO: Explain why _framework and _languages are NOT passed!
[self _getComponentURL:&componentURL andName:&_name
forNameOrURL:_name inFramework:nil languages:nil];
WOComponentDefinition *cdef;
cdef = [self __definitionForComponent:_name languages:_languages];
- if (cdef == nil) return nil;
+ if (cdef == nil)
+ return nil;
return (WOElement *)[cdef template];
}
-- (WOComponent *)pageWithName:(NSString *)_name languages:(NSArray *)_langs {
+- (id)pageWithName:(NSString *)_name languages:(NSArray *)_langs {
/*
TODO: this appears to be deprecated since the WOComponent initializer
is now -initWithContext: and we have no context over here ...
return [component autorelease];
}
-/* description */
-
-- (NSString *)description {
- return [NSString stringWithFormat:@"<%@[0x%08X]: path=%@>",
- [self class], self, self->base];
-
-}
-
/* KeyedData */
- (void)setData:(NSData *)_data
[self unlock];
}
+/* description */
+
+- (NSString *)description {
+ NSMutableString *ms;
+
+ ms = [NSMutableString stringWithCapacity:32];
+ [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
+ if ([self->base length] > 0)
+ [ms appendFormat:@" path='%@'", self->base];
+ [ms appendString:@">"];
+ return ms;
+}
+
@end /* WOResourceManager */