2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
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 "WOHTMLDynamicElement.h"
24 #include "WOElement+private.h"
25 #include <NGObjWeb/WOResourceManager.h>
26 #include <NGObjWeb/WOApplication.h>
29 @interface WOVBScript : WOHTMLDynamicElement
31 // WODynamicElement: extraAttributes
32 // WODynamicElement: otherTagString
34 WOAssociation *scriptFile;
35 WOAssociation *scriptString;
36 WOAssociation *scriptSource;
37 WOAssociation *hideInComment;
42 @implementation WOVBScript
44 - (id)initWithName:(NSString *)_name
45 associations:(NSDictionary *)_config
46 template:(WOElement *)_tmpl
48 if ((self = [super initWithName:_name associations:_config template:_tmpl])) {
49 self->scriptFile = OWGetProperty(_config, @"scriptFile");
50 self->scriptString = OWGetProperty(_config, @"scriptString");
51 self->scriptSource = OWGetProperty(_config, @"scriptSource");
52 self->hideInComment = OWGetProperty(_config, @"hideInComment");
57 #if !LIB_FOUNDATION_BOEHM_GC
59 RELEASE(self->scriptFile);
60 RELEASE(self->scriptString);
61 RELEASE(self->scriptSource);
62 RELEASE(self->hideInComment);
67 // ******************** responder ********************
69 #define StrVal(__x__) [self->__x__ stringValueInComponent:sComponent]
71 - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
72 if (![[_ctx request] isFromClientComponent]) {
73 WOComponent *sComponent = [_ctx component];
74 BOOL hide = [self->hideInComment boolValueInComponent:sComponent];
76 WOResponse_AddCString(_response, "<script language=\"VBScript\" ");
78 /* add URL to script */
79 if (self->scriptSource) {
80 WOResponse_AddCString(_response, " src=\"");
81 [_response appendContentHTMLAttributeValue:
82 [self->scriptSource stringValueInComponent:sComponent]];
83 WOResponse_AddCString(_response, "\"");
86 if (self->otherTagString) {
87 WOResponse_AddString(_response,
88 [self->otherTagString stringValueInComponent:
91 WOResponse_AddChar(_response, '>');
92 if (hide) WOResponse_AddCString(_response, "<!--hide from older browsers");
94 /* add a script string */
95 if (self->scriptString) {
96 NSString *s = [self->scriptString stringValueInComponent:sComponent];
98 if (s) WOResponse_AddString(_response, s);
101 /* add a script file */
102 if (self->scriptFile) {
105 s = [NSString stringWithContentsOfFile:
106 [self->scriptFile stringValueInComponent:sComponent]];
107 if (s) WOResponse_AddString(_response, s);
110 if (hide) WOResponse_AddCString(_response, "//hide from older browsers-->");
111 WOResponse_AddCString(_response, "</script>");
117 - (NSString *)associationDescription {
118 NSMutableString *str = [[NSMutableString alloc] init];
120 if (self->scriptFile) [str appendFormat:@" file=%@", self->scriptFile];
121 if (self->scriptString) [str appendFormat:@" string=%@", self->scriptString];
122 if (self->scriptSource) [str appendFormat:@" source=%@", self->scriptSource];
123 if (self->hideInComment)
124 [str appendFormat:@" hide=%@", self->hideInComment];
126 return AUTORELEASE(str);
129 @end /* WOVBScript */