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