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 "WOHyperlink.h"
24 @class NSString, NSDictionary;
25 @class WOElement, WOAssociation;
29 [WOHTMLDynamicElement]
31 _WOCommonStaticDAHyperlink
34 @interface _WOCommonStaticDAHyperlink : WOHyperlink
38 WOAssociation *string;
39 NSDictionary *queryParameters; /* associations beginning with ? */
40 BOOL sidInUrl; /* include session-id in wa URL ? */
42 @end /* _WOCommonStaticDAHyperlink */
44 #include "WOHyperlinkInfo.h"
45 #include "WOElement+private.h"
46 #include <NGObjWeb/WOApplication.h>
47 #include <NGObjWeb/WOAssociation.h>
50 @implementation _WOCommonStaticDAHyperlink
52 - (id)initWithName:(NSString *)_name
53 hyperlinkInfo:(WOHyperlinkInfo *)_info
54 template:(WOElement *)_t
56 if ((self = [super initWithName:_name hyperlinkInfo:_info template:_t])) {
59 self->template = [_t retain];
60 self->string = _info->string;
61 self->queryParameters = _info->queryParameters;
63 dc = [_info->actionClass stringValueInComponent:nil];
64 dn = [ _info->directActionName stringValueInComponent:nil];
66 if (![dc isEqualToString:@"DirectAction"] && ([dc length] != 0))
67 self->daName = [[NSString alloc] initWithFormat:@"%@/%@", dc, dn];
69 self->daName = [dn copy];
71 self->containsForm = NO;
72 self->sidInUrl = _info->sidInUrl;
78 [self->daName release];
79 [self->template release];
80 [self->string release];
81 [self->queryParameters release];
87 - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
88 WOComponent *sComponent;
89 NSMutableDictionary *qd;
91 if ([[_ctx request] isFromClientComponent])
94 sComponent = [_ctx component];
95 WOResponse_AddCString(_response, "<a href=\"");
98 if (self->queryParameters) {
102 qd = [NSMutableDictionary dictionaryWithCapacity:
103 [self->queryParameters count]];
104 keys = [self->queryParameters keyEnumerator];
105 while ((key = [keys nextObject])) {
108 assoc = [self->queryParameters objectForKey:key];
109 value = [assoc stringValueInComponent:sComponent];
111 [qd setObject:(value ? value : @"") forKey:key];
119 if (self->sidInUrl) {
120 if ([_ctx hasSession]) {
124 qd = [NSMutableDictionary dictionaryWithCapacity:2];
127 [qd setObject:[sn sessionID] forKey:WORequestValueSessionID];
129 if (![sn isDistributionEnabled]) {
130 [qd setObject:[[WOApplication application] number]
131 forKey:WORequestValueInstance];
136 WOResponse_AddString(_response,
137 [_ctx directActionURLForActionNamed:self->daName
138 queryDictionary:qd]);
140 WOResponse_AddCString(_response, "\"");
142 [self appendExtraAttributesToResponse:_response inContext:_ctx];
144 if (self->otherTagString) {
145 WOResponse_AddChar(_response, ' ');
146 WOResponse_AddString(_response,
147 [self->otherTagString stringValueInComponent:
150 [_response appendContentCharacter:'>'];
154 [self->template appendToResponse:_response inContext:_ctx];
157 [_response appendContentHTMLString:
158 [self->string stringValueInComponent:sComponent]];
162 WOResponse_AddCString(_response, "</a>");
165 @end /* _WOCommonStaticDAHyperlink */