2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
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 "WOHyperlink.h"
25 @class NSString, NSDictionary;
26 @class WOElement, WOAssociation;
30 [WOHTMLDynamicElement]
32 _WOCommonStaticDAHyperlink
35 @interface _WOCommonStaticDAHyperlink : WOHyperlink
39 WOAssociation *string;
40 NSDictionary *queryParameters; /* associations beginning with ? */
41 BOOL sidInUrl; /* include session-id in wa URL ? */
43 @end /* _WOCommonStaticDAHyperlink */
45 #include "WOHyperlinkInfo.h"
46 #include "WOElement+private.h"
47 #include <NGObjWeb/WOApplication.h>
48 #include <NGObjWeb/WOAssociation.h>
51 @implementation _WOCommonStaticDAHyperlink
53 - (id)initWithName:(NSString *)_name
54 hyperlinkInfo:(WOHyperlinkInfo *)_info
55 template:(WOElement *)_t
57 if ((self = [super initWithName:_name hyperlinkInfo:_info template:_t])) {
60 self->template = [_t retain];
61 self->string = _info->string;
62 self->queryParameters = _info->queryParameters;
64 dc = [_info->actionClass stringValueInComponent:nil];
65 dn = [ _info->directActionName stringValueInComponent:nil];
67 if (![dc isEqualToString:@"DirectAction"] && ([dc length] != 0))
68 self->daName = [[NSString alloc] initWithFormat:@"%@/%@", dc, dn];
70 self->daName = [dn copy];
72 self->containsForm = NO;
73 self->sidInUrl = _info->sidInUrl;
79 [self->daName release];
80 [self->template release];
81 [self->string release];
82 [self->queryParameters release];
88 - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
89 WOComponent *sComponent;
90 NSMutableDictionary *qd;
92 if ([[_ctx request] isFromClientComponent])
95 sComponent = [_ctx component];
96 WOResponse_AddCString(_response, "<a href=\"");
99 if (self->queryParameters) {
103 qd = [NSMutableDictionary dictionaryWithCapacity:
104 [self->queryParameters count]];
105 keys = [self->queryParameters keyEnumerator];
106 while ((key = [keys nextObject])) {
109 assoc = [self->queryParameters objectForKey:key];
110 value = [assoc stringValueInComponent:sComponent];
112 [qd setObject:(value ? value : @"") forKey:key];
120 if (self->sidInUrl) {
121 if ([_ctx hasSession]) {
125 qd = [NSMutableDictionary dictionaryWithCapacity:2];
128 [qd setObject:[sn sessionID] forKey:WORequestValueSessionID];
130 if (![sn isDistributionEnabled]) {
131 [qd setObject:[[WOApplication application] number]
132 forKey:WORequestValueInstance];
137 WOResponse_AddString(_response,
138 [_ctx directActionURLForActionNamed:self->daName
139 queryDictionary:qd]);
141 WOResponse_AddCString(_response, "\"");
143 [self appendExtraAttributesToResponse:_response inContext:_ctx];
145 if (self->otherTagString) {
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 */