]> err.no Git - scalable-opengroupware.org/blob - SOGo/UI/Common/UIxAppNavView.m
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@103 d1b88da0-ebda-0310-925b-ed51d...
[scalable-opengroupware.org] / SOGo / UI / Common / UIxAppNavView.m
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OGo
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21 // $Id$
22
23
24 #import <NGObjWeb/NGObjWeb.h>
25 #import <NGObjWeb/SoObject+SoDAV.h>
26 #import <NGObjWeb/WOContext+SoObjects.h>
27 #import <Foundation/Foundation.h>
28
29
30 @interface UIxAppNavView : WOComponent
31 {
32     id element;
33     id lastElement;
34 }
35
36 @end
37
38
39 @implementation UIxAppNavView
40
41 - (void)dealloc {
42     [self->element release];
43     [self->lastElement release];
44     [super dealloc];
45 }
46
47 - (void)setElement:(id)_element {
48     ASSIGN(self->element, _element);
49 }
50
51 - (id)element {
52     return self->element;
53 }
54
55 - (void)setLastElement:(id)_element {
56     ASSIGN(self->lastElement, _element);
57 }
58
59 - (id)lastElement {
60     return self->lastElement;
61 }
62
63 - (NSArray *)navPathElements {
64     NSArray *traversalObjects;
65     NSMutableArray *navPathComponents;
66     NSMutableString *navURL;
67     unsigned int i, count;
68
69     traversalObjects = [[self context] objectTraversalStack];
70     count = ([traversalObjects count] - 1); /* remove SoPageInvocation */
71     navPathComponents = [[NSMutableArray alloc] initWithCapacity:count];
72     navURL = [[NSMutableString alloc] initWithString:@"/"];
73
74     for(i = 0; i < count; i++) {
75         NSString *name, *url;
76         id obj;
77         
78         obj = [traversalObjects objectAtIndex:i];
79
80         name = [obj davDisplayName];
81         if(!name)
82             name = NSStringFromClass([obj class]);
83
84         [navURL appendString:name];
85         [navURL appendString:@"/"];
86         
87         if(! [name hasPrefix:@"ZideStore"]) {
88             NSMutableDictionary *c;
89
90             c = [[NSMutableDictionary alloc] initWithCapacity:2];
91             [c setObject:name forKey:@"name"];
92             url = [navURL copy];
93             [c setObject:url forKey:@"url"];
94             [url release];
95             [navPathComponents addObject:c];
96             [c release];
97         }
98     }
99
100     [self setLastElement:[navPathComponents lastObject]];
101     return [navPathComponents autorelease];
102 }
103
104 @end