]> err.no Git - sope/blob - sope-appserver/NGObjWeb/DynamicElements/WOHyperlinkInfo.m
renamed packages as discussed in the developer list
[sope] / sope-appserver / NGObjWeb / DynamicElements / WOHyperlinkInfo.m
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include "WOHyperlinkInfo.h"
24 #include "WOElement+private.h"
25 #include "WOHTMLDynamicElement.h"
26 #include "common.h"
27
28 @implementation WOHyperlinkInfo
29
30 - (id)initWithConfig:(NSMutableDictionary *)_config {
31   unsigned count;
32
33   if ((self->initialCount = count = [_config count]) == 0) {
34     NSLog(@"%s: missing associations for WOHyperlink !", __PRETTY_FUNCTION__);
35     RELEASE(self);
36     return nil;
37   }
38   
39   self->sidInUrl = YES;
40   
41   //NSLog(@"CONFIG: %@", _config);
42   
43   if ((self->action = OWGetProperty(_config, @"action"))) {
44     count--;
45 #if DEBUG
46     if (count > 0) {
47       if ([_config objectForKey:@"pageName"] ||
48           [_config objectForKey:@"href"]     ||
49           [_config objectForKey:@"directActionName"] ||
50           [_config objectForKey:@"actionClass"]) {
51         NSLog(@"WARNING: inconsistent association settings in WOHyperlink !"
52               @" (assign only one of pageName, href, "
53               @"directActionName or action)");
54       }
55     }
56 #endif
57     if ([self->action isValueConstant]) {
58       /* make a direct-action ... */
59       self->directActionName = self->action;
60       self->action = nil;
61
62       if (count > 0) {
63         if ((self->actionClass = OWGetProperty(_config,@"actionClass")))
64           count--;
65       }
66       if (count > 0) {
67         WOAssociation *sidInUrlAssoc;
68         
69         if ((sidInUrlAssoc = OWGetProperty(_config, @"?wosid"))) {
70           self->sidInUrl = [sidInUrlAssoc boolValueInComponent:nil];
71           RELEASE(sidInUrlAssoc);
72           count--;
73         }
74         else
75           self->sidInUrl = YES;
76       }
77       else
78         self->sidInUrl = YES;
79     }
80   }
81   else if ((self->pageName = OWGetProperty(_config, @"pageName"))) {
82     count--;
83 #if DEBUG
84     if (count > 0) {
85       if ([_config objectForKey:@"action"] ||
86           [_config objectForKey:@"href"]     ||
87           [_config objectForKey:@"directActionName"] ||
88           [_config objectForKey:@"actionClass"]) {
89         NSLog(@"WARNING: inconsistent association settings in WOHyperlink !"
90               @" (assign only one of pageName, href, "
91               @"directActionName or action)");
92       }
93     }
94 #endif
95   }
96   else if ((self->href = OWGetProperty(_config, @"href"))) {
97     count--;
98     if (count > 0) {
99       WOAssociation *sidInUrlAssoc;
100       
101       if ((sidInUrlAssoc = OWGetProperty(_config, @"?wosid"))) {
102         self->sidInUrl = [sidInUrlAssoc boolValueInComponent:nil];
103         RELEASE(sidInUrlAssoc);
104         count--;
105       }
106       else
107         self->sidInUrl = NO;
108     }
109 #if DEBUG
110     if (count > 0) {
111       if ([_config objectForKey:@"action"] ||
112           [_config objectForKey:@"pageName"]     ||
113           [_config objectForKey:@"directActionName"] ||
114           [_config objectForKey:@"actionClass"]) {
115         NSLog(@"WARNING: inconsistent association settings in WOHyperlink !"
116               @" (assign only one of pageName, href, "
117               @"directActionName or action)");
118       }
119     }
120 #endif
121   }
122   else if ((self->directActionName = OWGetProperty(_config,@"directActionName"))) {
123     count--;
124     if (count > 0) {
125       if ((self->actionClass = OWGetProperty(_config,@"actionClass")))
126         count--;
127     }
128     if (count > 0) {
129       WOAssociation *sidInUrlAssoc;
130       
131       if ((sidInUrlAssoc = OWGetProperty(_config, @"?wosid"))) {
132         self->sidInUrl = [sidInUrlAssoc boolValueInComponent:nil];
133         RELEASE(sidInUrlAssoc);
134         count--;
135       }
136       else
137         self->sidInUrl = YES;
138     }
139     
140 #if DEBUG
141     if (count > 0) {
142       if ([_config objectForKey:@"action"] ||
143           [_config objectForKey:@"href"]     ||
144           [_config objectForKey:@"pageName"]) {
145         NSLog(@"WARNING: inconsistent association settings in WOHyperlink !"
146               @" (assign only one of pageName, href, "
147               @"directActionName or action)");
148       }
149     }
150 #endif
151   }
152   else {
153     NSLog(@"%s: missing link-type specified for WOHyperlink (config=%@) !",
154           __PRETTY_FUNCTION__, _config);
155     RELEASE(self);
156     return nil;
157   }
158   
159   if (count > 0) {
160     if ((self->string = OWGetProperty(_config, @"string"))) {
161       count--;
162       assocCount++;
163     }
164   }
165   if (count > 0) {
166     if ((self->fragmentIdentifier=OWGetProperty(_config, @"fragmentIdentifier"))) {
167       count--;
168       assocCount++;
169     }
170   }
171   if (count > 0) {
172     if ((self->target = OWGetProperty(_config, @"target"))) {
173       count--;
174       assocCount++;
175     }
176   }
177   if (count > 0) {
178     if ((self->queryDictionary = OWGetProperty(_config, @"queryDictionary"))) {
179       count--;
180       assocCount++;
181     }
182   }
183   if (count > 0) {
184     if ((self->queryParameters = OWExtractQueryParameters(_config))) {
185       count--;
186       assocCount++;
187     }
188   }
189   if (count > 0) {
190     if ((self->disabled = OWGetProperty(_config, @"disabled"))) {
191       count--;
192       assocCount++;
193     }
194   }
195
196   if (count > 0) {
197     if ((self->filename = OWGetProperty(_config, @"filename"))) {
198       count--;
199       assocCount++;
200     }
201   }
202   if (count > 0) {
203     if ((self->framework = OWGetProperty(_config, @"framework"))) {
204       count--;
205       assocCount++;
206     }
207   }
208   if (count > 0) {
209     if ((self->src = OWGetProperty(_config, @"src"))) {
210       count--;
211       assocCount++;
212     }
213   }
214   if (count > 0) {
215     if ((self->disabledFilename = OWGetProperty(_config, @"disabledFilename"))) {
216       count--;
217       assocCount++;
218     }
219   }
220   
221   self->rest = _config;
222   
223   return self;
224 }
225
226 @end /* WOHyperlinkInfo */