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 #import <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;
43 @implementation UIxMailMoveToPopUp
46 [self->identifier release];
47 [self->callback release];
48 [self->rootNodes release];
55 - (void)setIdentifier:(NSString *)_identifier {
56 ASSIGN(self->identifier, _identifier);
58 - (NSString *)identifier {
59 return self->identifier;
62 - (void)setCallback:(NSString *)_callback {
63 ASSIGN(self->callback, _callback);
65 - (NSString *)callback {
66 return self->callback;
69 - (void)setRootNodes:(id)_rootNodes {
70 ASSIGN(self->rootNodes, _rootNodes);
73 return self->rootNodes;
76 - (void)setItem:(id)_item {
77 ASSIGN(self->item, _item);
83 - (NSArray *)sortedNodes {
87 r = [NSMutableArray arrayWithCapacity:10];
90 dict = [[self->rootNodes objectForKey:@"children"] objectAtIndex:0];
91 [self _appendEntriesFromNodeDict:dict toList:r withPrefix:nil];
95 - (void)_appendEntriesFromNodeDict:(NSDictionary *)_dict
96 toList:(NSMutableArray *)_list
97 withPrefix:(NSString *)_pathPrefix
99 NSMutableDictionary *e;
100 NSString *title, *link;
104 title = [_dict objectForKey:@"title"];
105 link = [_dict objectForKey:@"link"];
107 e = [[NSMutableDictionary alloc] initWithCapacity:2];
108 _pathPrefix = (_pathPrefix == nil)
110 : [NSString stringWithFormat:@"%@.%@", _pathPrefix, title];
111 [e setObject:_pathPrefix forKey:@"title"];
112 [e setObject:link forKey:@"link"];
114 [e release]; e = nil;
116 children = [_dict objectForKey:@"children"];
117 count = [children count];
118 for (i = 0; i < count; i++) {
121 dict = [children objectAtIndex:i];
122 [self _appendEntriesFromNodeDict:dict
124 withPrefix:_pathPrefix];
128 - (NSString *)itemDisplayString {
129 return [self->item objectForKey:@"title"];
132 - (NSString *)itemURL {
133 return [self->item objectForKey:@"link"];
136 - (NSString *)itemDisabledValue {
137 return [[self itemURL] isEqualToString:@"."] ? @" disabled" : @"";
142 - (NSString *)selectItemJS {
143 static NSString *selectJS = \
144 @"javascript:if(!this.hasAttribute('disabled')) %@('%@');";
145 return [NSString stringWithFormat:selectJS, self->callback, [self itemURL]];
148 @end /* UIxMailMoveToPopUp */