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 <NGObjWeb/WODynamicElement.h>
25 @interface WETableMatrixContentImp : WODynamicElement
27 WOAssociation *elementName;
28 WOAssociation *rowspan; /* a write variable */
29 WOAssociation *colspan; /* a write variable */
35 @interface WETableMatrixContent : WETableMatrixContentImp
38 @interface WETableMatrixNoContent : WETableMatrixContentImp
41 #include <NGObjWeb/NGObjWeb.h>
44 @implementation WETableMatrixContentImp
46 - (id)initWithName:(NSString *)_name
47 associations:(NSDictionary *)_config
48 template:(WOElement *)_subs
50 if ((self = [super initWithName:_name associations:_config template:_subs])) {
51 self->elementName = WOExtGetProperty(_config, @"elementName");
52 self->rowspan = WOExtGetProperty(_config, @"rowspan");
53 self->colspan = WOExtGetProperty(_config, @"colspan");
55 self->template = [_subs retain];
61 RELEASE(self->rowspan);
62 RELEASE(self->colspan);
63 RELEASE(self->elementName);
64 RELEASE(self->template);
70 - (NSString *)modeKey {
71 [self logWithFormat:@"ERROR: subclasses should override -modeKey!"];
75 /* response generation */
77 - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
82 if ((tmp = [_ctx valueForKey:@"WETableMatrix_Query"])) {
83 [tmp addObject:[self modeKey]];
87 if ((tmp = [_ctx valueForKey:@"WETableMatrix_Mode"]) == nil)
90 if (![tmp isEqualToString:[self modeKey]])
93 cspan = [[_ctx objectForKey:@"WETableMatrix_ColSpan"] intValue];
94 if (cspan < 1) cspan = 1;
95 rspan = [[_ctx objectForKey:@"WETableMatrix_RowSpan"] intValue];
96 if (rspan < 1) rspan = 1;
98 if ([self->colspan isValueSettable]) {
99 [self->colspan setValue:[NSNumber numberWithInt:cspan]
100 inComponent:[_ctx component]];
102 if ([self->rowspan isValueSettable]) {
103 [self->rowspan setValue:[NSNumber numberWithInt:rspan]
104 inComponent:[_ctx component]];
107 tag = [self->elementName stringValueInComponent:[_ctx component]];
113 [_response appendContentString:@"<"];
114 [_response appendContentString:tag];
117 sprintf(buf, "%i", cspan);
118 s = [[NSString alloc] initWithCString:buf];
119 [_response appendContentString:@" colspan=\""];
120 [_response appendContentString:s];
121 [_response appendContentString:@"\""];
125 sprintf(buf, "%i", rspan);
126 s = [[NSString alloc] initWithCString:buf];
127 [_response appendContentString:@" rowspan=\""];
128 [_response appendContentString:s];
129 [_response appendContentString:@"\""];
133 [self appendExtraAttributesToResponse:_response inContext:_ctx];
135 [_response appendContentString:@">"];
138 [self->template appendToResponse:_response inContext:_ctx];
141 [_response appendContentString:@"</"];
142 [_response appendContentString:tag];
143 [_response appendContentString:@">"];
147 @end /* WETableMatrixContentImp */
149 @implementation WETableMatrixContent
151 - (NSString *)modeKey {
155 @end /* WETableMatrixContent */
157 @implementation WETableMatrixNoContent
159 - (NSString *)modeKey {
163 @end /* WETableMatrixNoContent */