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 "WOGenericElement.h"
24
@interface WOGenericContainer : WOGenericElement
26
// WODynamicElement: extraAttributes
27
// WODynamicElement: otherTagString
28
// WOGenericContainer: tagName
35
#import "WOElement+private.h"
38
// TODO(perf): ASCII Tags (appendContentCString)
39
// TODO(perf): constant tags
41
#define TagNameType_Assoc 0
42
#define TagNameType_String 1
43
#define TagNameType_ASCII 2
45
@implementation WOGenericContainer
47
- (id)initWithName:(NSString *)_name
48
associations:(NSDictionary *)_config
49
template:(WOElement *)_c
51
if ((self = [super initWithName:_name associations:_config template:_c])) {
52
self->template = [_c retain];
58
[self->template release];
64
- (WOElement *)template {
65
return self->template;
68
// ******************** responder ********************
70
- (void)takeValuesFromRequest:(WORequest *)_req inContext:(WOContext *)_ctx {
71
[self->template takeValuesFromRequest:_req inContext:_ctx];
73
- (id)invokeActionForRequest:(WORequest *)_req inContext:(WOContext *)_ctx {
74
return [self->template invokeActionForRequest:_req inContext:_ctx];
77
- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
78
WOComponent *sComponent;
81
if ([[_ctx request] isFromClientComponent])
84
sComponent = [_ctx component];
85
switch (self->tagNameType) {
86
case TagNameType_Assoc:
87
if ((tag = [(id)self->tagName stringValueInComponent:sComponent]) == nil)
90
case TagNameType_String:
91
if ((tag = self->tagName) == nil) tag = @"p";
93
case TagNameType_ASCII:
99
WOResponse_AddChar(_response, '<');
101
WOResponse_AddString(_response, tag);
103
else if (self->tagNameType == TagNameType_ASCII) {
104
WOResponse_AddCString(_response, self->tagName);
107
[self _appendAttributesToResponse:_response inContext:_ctx];
109
if (self->otherTagString) {
110
WOResponse_AddChar(_response, ' ');
111
WOResponse_AddString(_response,
112
[self->otherTagString stringValueInComponent:
115
WOResponse_AddChar(_response, '>');
117
[self->template appendToResponse:_response inContext:_ctx];
119
WOResponse_AddCString(_response, "</");
121
WOResponse_AddString(_response, tag);
123
else if (self->tagNameType == TagNameType_ASCII) {
124
WOResponse_AddCString(_response, self->tagName);
126
WOResponse_AddChar(_response, '>');
129
@end /* WOGenericContainer */