2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include "ODResourceManager.h"
26 @interface WOResourceManager(Privates)
28 - (id)definitionForComponent:(NSString *)_name
29 languages:(NSArray *)_languages;
30 - (NSString *)pathToComponentNamed:(NSString *)_name
31 inFramework:(NSString *)_fw;
35 @implementation ODResourceManager
38 return [super version] + 0 /* v3 */;
41 static BOOL isInitialized = NO;
44 NSAssert2([super version] == 3,
45 @"invalid superclass (%@) version %i !",
46 NSStringFromClass([self superclass]), [super version]);
48 if (isInitialized) return;
51 defs = [NSDictionary dictionaryWithObjectsAndKeys:
52 [NSArray arrayWithObjects:
53 @"xml", @"wml", @"xhtml", nil],
54 @"ODXMLComponentExtensions",
56 // .svg, ... can be added using the default
58 [[NSUserDefaults standardUserDefaults] registerDefaults:defs];
61 + (NSArray *)xmlComponentExtensions {
62 static NSArray *exts = nil;
65 exts = [[[NSUserDefaults standardUserDefaults]
66 arrayForKey:@"ODXMLComponentExtensions"]
74 RELEASE(self->nameToCDef);
80 - (NSString *)pathToComponentNamed:(NSString *)_name
81 inFramework:(NSString *)_framework
82 languages:(NSArray *)_langs
84 /* search for component template .. */
88 NSLog(@"WARNING(%s): tried to get path to component with <nil> name !",
94 /* scan for name.$ext resource ... */
99 e = [[[self class] xmlComponentExtensions] objectEnumerator];
101 while ((ext = [e nextObject])) {
102 NSString *templateName;
105 templateName = [_name stringByAppendingPathExtension:ext];
107 path = [self pathForResourceNamed:templateName
108 inFramework:_framework
110 if (path) return path;
114 /* this resource manager does not search in WOProjectSearchPath ... */
116 return [super pathToComponentNamed:_name inFramework:_framework];
119 - (id)definitionForComponent:(NSString *)_name
120 languages:(NSArray *)_languages
128 if (_languages == nil)
129 _languages = [NSArray array];
131 /* look into cache */
133 if ([[WOApplication application] isCachingEnabled]) {
134 cacheKey = [NSArray arrayWithObjects:_name, _languages, nil];
136 if ((cdef = [self->nameToCDef objectForKey:cacheKey]))
144 /* look for .wo component if no XML component could be found ... */
147 cdef = [super definitionForComponent:_name languages:_languages];
154 @end /* ODResourceManager */