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
22 #include <NGObjWeb/WODynamicElement.h>
24 @interface WETableMatrixContentImp : WODynamicElement
26 WOAssociation *elementName;
27 WOAssociation *rowspan; /* a write variable */
28 WOAssociation *colspan; /* a write variable */
34 @interface WETableMatrixContent : WETableMatrixContentImp
37 @interface WETableMatrixNoContent : WETableMatrixContentImp
40 #include <NGObjWeb/NGObjWeb.h>
43 @implementation WETableMatrixContentImp
45 - (id)initWithName:(NSString *)_name
46 associations:(NSDictionary *)_config
47 template:(WOElement *)_subs
49 if ((self = [super initWithName:_name associations:_config template:_subs])) {
50 self->elementName = WOExtGetProperty(_config, @"elementName");
51 self->rowspan = WOExtGetProperty(_config, @"rowspan");
52 self->colspan = WOExtGetProperty(_config, @"colspan");
54 self->template = [_subs retain];
60 RELEASE(self->rowspan);
61 RELEASE(self->colspan);
62 RELEASE(self->elementName);
63 RELEASE(self->template);
69 - (NSString *)modeKey {
70 [self logWithFormat:@"ERROR: subclasses should override -modeKey!"];
74 /* response generation */
76 - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
81 if ((tmp = [_ctx valueForKey:@"WETableMatrix_Query"])) {
82 [tmp addObject:[self modeKey]];
86 if ((tmp = [_ctx valueForKey:@"WETableMatrix_Mode"]) == nil)
89 if (![tmp isEqualToString:[self modeKey]])
92 cspan = [[_ctx objectForKey:@"WETableMatrix_ColSpan"] intValue];
93 if (cspan < 1) cspan = 1;
94 rspan = [[_ctx objectForKey:@"WETableMatrix_RowSpan"] intValue];
95 if (rspan < 1) rspan = 1;
97 if ([self->colspan isValueSettable]) {
98 [self->colspan setValue:[NSNumber numberWithInt:cspan]
99 inComponent:[_ctx component]];
101 if ([self->rowspan isValueSettable]) {
102 [self->rowspan setValue:[NSNumber numberWithInt:rspan]
103 inComponent:[_ctx component]];
106 tag = [self->elementName stringValueInComponent:[_ctx component]];
112 [_response appendContentString:@"<"];
113 [_response appendContentString:tag];
116 sprintf(buf, "%i", cspan);
117 s = [[NSString alloc] initWithCString:buf];
118 [_response appendContentString:@" colspan=\""];
119 [_response appendContentString:s];
120 [_response appendContentString:@"\""];
124 sprintf(buf, "%i", rspan);
125 s = [[NSString alloc] initWithCString:buf];
126 [_response appendContentString:@" rowspan=\""];
127 [_response appendContentString:s];
128 [_response appendContentString:@"\""];
132 [self appendExtraAttributesToResponse:_response inContext:_ctx];
134 [_response appendContentString:@">"];
137 [self->template appendToResponse:_response inContext:_ctx];
140 [_response appendContentString:@"</"];
141 [_response appendContentString:tag];
142 [_response appendContentString:@">"];
146 @end /* WETableMatrixContentImp */
148 @implementation WETableMatrixContent
150 - (NSString *)modeKey {
154 @end /* WETableMatrixContent */
156 @implementation WETableMatrixNoContent
158 - (NSString *)modeKey {
162 @end /* WETableMatrixNoContent */