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