2 Copyright (C) 2000-2005 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
22 #include <NGObjWeb/WOComponent.h>
24 @class NSString, NSMutableArray, NSDictionary;
26 @interface UIxMailMoveToPopUp : WOComponent
34 - (NSString *)itemDisplayString;
35 - (NSString *)itemURL;
37 - (void)_appendEntriesFromNodeDict:(NSDictionary *)_dict
38 toList:(NSMutableArray *)_list
39 withPrefix:(NSString *)_pathPrefix;
45 @implementation UIxMailMoveToPopUp
48 [self->identifier release];
49 [self->callback release];
50 [self->rootNodes release];
57 - (void)setIdentifier:(NSString *)_identifier {
58 ASSIGN(self->identifier, _identifier);
60 - (NSString *)identifier {
61 return self->identifier;
64 - (void)setCallback:(NSString *)_callback {
65 ASSIGN(self->callback, _callback);
67 - (NSString *)callback {
68 return self->callback;
71 - (void)setRootNodes:(id)_rootNodes {
72 ASSIGN(self->rootNodes, _rootNodes);
75 return self->rootNodes;
78 - (void)setItem:(id)_item {
79 ASSIGN(self->item, _item);
85 - (NSArray *)sortedNodes {
89 r = [NSMutableArray arrayWithCapacity:10];
92 dict = [[self->rootNodes objectForKey:@"children"] objectAtIndex:0];
93 [self _appendEntriesFromNodeDict:dict toList:r withPrefix:nil];
97 - (void)_appendEntriesFromNodeDict:(NSDictionary *)_dict
98 toList:(NSMutableArray *)_list
99 withPrefix:(NSString *)_pathPrefix
101 NSMutableDictionary *e;
102 NSString *title, *link;
106 title = [_dict objectForKey:@"title"];
107 link = [_dict objectForKey:@"link"];
109 e = [[NSMutableDictionary alloc] initWithCapacity:2];
110 _pathPrefix = (_pathPrefix == nil)
112 : [NSString stringWithFormat:@"%@.%@", _pathPrefix, title];
113 [e setObject:_pathPrefix forKey:@"title"];
114 [e setObject:link forKey:@"link"];
116 [e release]; e = nil;
118 children = [_dict objectForKey:@"children"];
119 count = [children count];
120 for (i = 0; i < count; i++) {
123 dict = [children objectAtIndex:i];
124 [self _appendEntriesFromNodeDict:dict
126 withPrefix:_pathPrefix];
130 - (NSString *)itemDisplayString {
131 return [self->item objectForKey:@"title"];
134 - (NSString *)itemURL {
135 return [self->item objectForKey:@"link"];
138 - (NSString *)itemDisabledValue {
139 return [[self itemURL] isEqualToString:@"."] ? @" disabled" : @"";
144 - (NSString *)selectItemJS {
145 static NSString *selectJS = \
146 @"javascript:if(!this.hasAttribute('disabled')) %@('%@');";
147 return [NSString stringWithFormat:selectJS, self->callback, [self itemURL]];
150 @end /* UIxMailMoveToPopUp */