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"
23
#include "WOHyperlinkInfo.h"
24
#include "WOCompoundElement.h"
25
#include <NGObjWeb/WOAssociation.h>
28
@implementation _WOTemporaryHyperlink
30
static Class _WOSimpleActionHyperlinkClass = Nil;
31
static Class _WOSimpleStringActionHyperlinkClass = Nil;
32
static Class _WOActionHyperlinkClass = Nil;
33
static Class _WOPageHyperlinkClass = Nil;
34
static Class _WOHrefHyperlinkClass = Nil;
35
static Class _WOCommonStaticDAHyperlinkClass = Nil;
36
static Class _WODirectActionHyperlinkClass = Nil;
39
static BOOL didInit = NO;
43
_WOSimpleActionHyperlinkClass =
44
NSClassFromString(@"_WOSimpleActionHyperlink");
45
_WOSimpleStringActionHyperlinkClass =
46
NSClassFromString(@"_WOSimpleStringActionHyperlink");
48
_WOActionHyperlinkClass = NSClassFromString(@"_WOActionHyperlink");
49
_WOPageHyperlinkClass = NSClassFromString(@"_WOPageHyperlink");
50
_WOHrefHyperlinkClass = NSClassFromString(@"_WOHrefHyperlink");
52
_WOCommonStaticDAHyperlinkClass =
53
NSClassFromString(@"_WOCommonStaticDAHyperlink");
54
_WODirectActionHyperlinkClass =
55
NSClassFromString(@"_WODirectActionHyperlink");
58
- (id)initWithName:(NSString *)_name
59
associations:(NSDictionary *)_config
60
template:(WOElement *)_t
62
WOHyperlinkInfo *info;
63
Class linkClass = Nil;
65
if ((info = [[WOHyperlinkInfo alloc] initWithConfig:(id)_config]) == nil) {
70
if (info->assocCount == 0)
71
linkClass = [_WOSimpleActionHyperlinkClass class];
72
else if ((info->assocCount == 1) && (info->string != nil))
73
linkClass = [_WOSimpleStringActionHyperlinkClass class];
75
linkClass = [_WOActionHyperlinkClass class];
77
else if (info->pageName) {
78
linkClass = [_WOPageHyperlinkClass class];
80
else if (info->href) {
81
linkClass = [_WOHrefHyperlinkClass class];
83
else if (info->directActionName) {
86
if (info->assocCount < 3) {
87
if ([info->directActionName isValueConstant]) {
88
if (info->actionClass == nil ||
89
([info->actionClass isValueConstant])) {
90
if (info->assocCount == 1) {
91
if (info->queryParameters != nil || info->string != nil)
92
linkClass = [_WOCommonStaticDAHyperlinkClass class];
94
else if (info->assocCount == 2 &&
95
(info->queryParameters != nil) &&
96
(info->string != nil)) {
97
linkClass = [_WOCommonStaticDAHyperlinkClass class];
103
if (linkClass == Nil)
104
linkClass = [_WODirectActionHyperlinkClass class];
107
NSLog(@"%s: found no setting for link named '%@', assocs %@",
108
__PRETTY_FUNCTION__, _name, _config);
113
[[linkClass alloc] initWithName:_name hyperlinkInfo:info template:_t];
114
[info release]; info = nil;
118
- (id)initWithName:(NSString *)_name
119
associations:(NSDictionary *)_associations
120
contentElements:(NSArray *)_contents
122
WOCompoundElement *template;
125
count = [_contents count];
130
else if (count == 1) {
131
template = [_contents objectAtIndex:0];
134
template = [[WOCompoundElement allocForCount:[_contents count]
136
initWithContentElements:_contents];
139
return [self initWithName:_name
140
associations:_associations
145
NSLog(@"ERROR: called dealloc on %@", self);
152
@end /* _WOTemporaryHyperlink */