2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE 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 SOPE 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 SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 @interface _WOConstResourceImage : WOImage
26 NSString *filename; // path relative to WebServerResources
30 #include "WOElement+private.h"
31 #include <NGObjWeb/WOApplication.h>
32 #include <NGObjWeb/WOResourceManager.h>
35 @implementation _WOConstResourceImage
37 static BOOL debugOn = NO;
39 - (id)initWithName:(NSString *)_name
40 associations:(NSDictionary *)_config
41 template:(WOElement *)_t
43 if ((self = [super initWithName:_name associations:_config template:_t])) {
46 tmp = OWGetProperty(_config, @"filename");
47 self->filename = [[tmp stringValueInComponent:nil] copy];
50 if (self->filename == nil) {
51 NSLog(@"missing filename association for WOImage ..");
57 if ([_config objectForKey:@"value"] ||
58 [_config objectForKey:@"data"] ||
59 [_config objectForKey:@"mimeType"] ||
60 [_config objectForKey:@"key"] ||
61 [_config objectForKey:@"src"]) {
62 NSLog(@"WARNING: inconsistent association settings in WOImage !"
63 @" (assign only one of value, src, data or filename)");
71 [self->filename release];
77 - (void)_appendSrcToResponse:(WOResponse *)_resp inContext:(WOContext *)_ctx {
78 WOComponent *sComponent;
81 WOResourceManager *rm;
82 NSString *frameworkName;
84 sComponent = [_ctx component];
86 if (self->filename == nil) {
87 [_resp appendContentHTMLAttributeValue:
88 @"/missingImage?reason=nilfilenamebinding"];
89 [self debugWithFormat:@"missing 'filename' binding value ..."];
93 /* this has no measurable effect on performance ... */
94 if ((rm = [[_ctx component] resourceManager]) == nil)
95 rm = [[_ctx application] resourceManager];
97 languages = [_ctx resourceLookupLanguages];
100 [self debugWithFormat:@"WOImage: filename '%@'\n rm %@\n languages %@",
101 self->filename, rm, [languages componentsJoinedByString:@","]];
105 'framework' binding is not set in that case -> use parent component's
108 frameworkName = [[_ctx component] frameworkName];
109 uFi = [rm urlForResourceNamed:self->filename
110 inFramework:frameworkName
112 request:[_ctx request]];
115 @"%@: did not find resource '%@'", sComponent, self->filename];
116 uFi = [@"/missingImage?" stringByAppendingString:self->filename];
120 [self debugWithFormat:@"WOImage: constant resource URL: '%@'", uFi];
122 [_resp appendContentHTMLAttributeValue:uFi];
127 - (BOOL)isDebuggingEnabled {
133 - (NSString *)associationDescription {
134 NSMutableString *str = [NSMutableString stringWithCapacity:64];
136 [str appendFormat:@" filename=%@", self->filename];
137 [str appendString:[super associationDescription]];
141 @end /* _WOConstResourceImage */