2 Copyright (C) 2000-2004 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
23 #include <NGObjWeb/WOComponent.h>
25 @class NSString, NSMutableArray, NSDictionary;
27 @interface UIxMailMoveToPopUp : WOComponent
35 - (NSString *)itemDisplayString;
36 - (NSString *)itemURL;
38 - (void)_appendEntriesFromNodeDict:(NSDictionary *)_dict
39 toList:(NSMutableArray *)_list
40 withPrefix:(NSString *)_pathPrefix;
46 @implementation UIxMailMoveToPopUp
49 [self->identifier release];
50 [self->callback release];
51 [self->rootNodes release];
56 - (void)setIdentifier:(NSString *)_identifier {
57 ASSIGN(self->identifier, _identifier);
59 - (NSString *)identifier {
60 return self->identifier;
63 - (void)setCallback:(NSString *)_callback {
64 ASSIGN(self->callback, _callback);
66 - (NSString *)callback {
67 return self->callback;
70 - (void)setRootNodes:(id)_rootNodes {
71 ASSIGN(self->rootNodes, _rootNodes);
74 return self->rootNodes;
77 - (void)setItem:(id)_item {
78 ASSIGN(self->item, _item);
84 - (NSArray *)sortedNodes {
88 r = [NSMutableArray arrayWithCapacity:10];
91 dict = [[self->rootNodes objectForKey:@"children"] objectAtIndex:0];
92 [self _appendEntriesFromNodeDict:dict toList:r withPrefix:nil];
96 - (void)_appendEntriesFromNodeDict:(NSDictionary *)_dict
97 toList:(NSMutableArray *)_list
98 withPrefix:(NSString *)_pathPrefix
100 NSMutableDictionary *e;
101 NSString *title, *link;
105 title = [_dict objectForKey:@"title"];
106 link = [_dict objectForKey:@"link"];
108 e = [[NSMutableDictionary alloc] initWithCapacity:2];
109 _pathPrefix = (_pathPrefix == nil)
111 : [NSString stringWithFormat:@"%@.%@", _pathPrefix, title];
112 [e setObject:_pathPrefix forKey:@"title"];
113 [e setObject:link forKey:@"link"];
115 [e release]; e = nil;
117 children = [_dict objectForKey:@"children"];
118 count = [children count];
119 for (i = 0; i < count; i++) {
122 dict = [children objectAtIndex:i];
123 [self _appendEntriesFromNodeDict:dict
125 withPrefix:_pathPrefix];
129 - (NSString *)itemDisplayString {
130 return [self->item objectForKey:@"title"];
133 - (NSString *)itemURL {
134 return [self->item objectForKey:@"link"];
137 - (NSString *)itemDisabledValue {
138 return [[self itemURL] isEqualToString:@"."] ? @" disabled" : @"";
143 - (NSString *)selectItemJS {
144 static NSString *selectJS = \
145 @"javascript:if(!this.hasAttribute('disabled')) %@('%@');";
146 return [NSString stringWithFormat:selectJS, self->callback, [self itemURL]];
149 @end /* UIxMailMoveToPopUp */