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