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 "WOElement+private.h"
24 #include "WOHyperlinkInfo.h"
25 #include "WOCompoundElement.h"
26 #include <NGObjWeb/WOApplication.h>
27 #include <NGObjWeb/WOResourceManager.h>
28 #include <NGExtensions/NSString+Ext.h>
31 #define PROFILE_CLUSTERS 0
34 # warning HYPERLINK CLUSTER PROFILING IS TURNED ON !!!
37 // TODO(perf): all adding of links to an anker can probably be added using
38 // appendContentCString because they are already escaped
39 // => check that for umlauts in downloads !
42 WOHyperlink associations:
44 href | pageName | action | (directActionName & actionClass)
51 Concrete Class Hierachy
60 _WODirectActionHyperlink
61 _WOSimpleActionHyperlink
62 _WOSimpleStringActionHyperlink
63 _WOCommonStaticDAHyperlink
66 @implementation WOHyperlink
69 return [super version] + 2 /* v4 */;
72 NSAssert2([super version] == 2,
73 @"invalid superclass (%@) version %i !",
74 NSStringFromClass([self superclass]), [super version]);
77 + (id)allocWithZone:(NSZone *)zone {
78 static Class WOHyperlinkClass = Nil;
79 static _WOTemporaryHyperlink *temporaryHyperlink = nil;
81 if (WOHyperlinkClass == Nil)
82 WOHyperlinkClass = [WOHyperlink class];
83 if (temporaryHyperlink == nil)
84 temporaryHyperlink = [_WOTemporaryHyperlink allocWithZone:zone];
86 if (self == WOHyperlinkClass)
87 return temporaryHyperlink;
90 static unsigned totalCount = 0;
91 static unsigned countSimpleAction = 0;
92 static unsigned countAction = 0;
93 static unsigned countHref = 0;
94 static unsigned countDirectAction = 0;
95 static unsigned countCommonDA = 0;
96 static unsigned countOther = 0;
98 if (self == [_WOSimpleActionHyperlink class])
100 else if (self == [_WOActionHyperlink class])
102 else if (self == [_WODirectActionHyperlink class])
104 else if (self == [_WOHrefHyperlink class])
106 else if (self == NSClassFromString(@"_WOCommonStaticDAHyperlink"))
111 if (totalCount % 30 == 0) {
112 NSLog(@"WOHyperlink statistics:\n"
114 @" simple action: %d,"
116 @" direct action: %d,"
120 totalCount, countSimpleAction, countAction,
121 countDirectAction, countCommonDA, countHref, countOther);
124 return NSAllocateObject(self, 0, zone);
128 - (id)initWithName:(NSString *)_name
129 hyperlinkInfo:(WOHyperlinkInfo *)_info
130 template:(WOElement *)_t
132 return [super initWithName:_name associations:nil template:_t];
135 @end /* WOHyperlink */