]> err.no Git - scalable-opengroupware.org/blob - SOGo/UI/Common/UIxAppNavView.m
added ability to have per-page JavaScript files in the frame
[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 /* accessors */
47
48 - (void)setElement:(id)_element {
49   ASSIGN(self->element, _element);
50 }
51 - (id)element {
52   return self->element;
53 }
54
55 - (void)setLastElement:(id)_element {
56   ASSIGN(self->lastElement, _element);
57 }
58 - (id)lastElement {
59   return self->lastElement;
60 }
61
62 /* navigation */
63
64 - (NSArray *)navPathElements {
65   NSArray        *traversalObjects;
66   NSMutableArray *navPathComponents;
67   unsigned int   i, count;
68   
69   traversalObjects = [[self context] objectTraversalStack];
70   count = ([traversalObjects count] - 1); /* remove SoPageInvocation */
71   
72   navPathComponents = [[NSMutableArray alloc] initWithCapacity:count];
73   for (i = 0; i < count; i++) {
74     NSString *name;
75     id obj;
76     
77     obj = [traversalObjects objectAtIndex:i];
78     
79     name = [obj davDisplayName];
80     if ([name length] == 0)
81       name = NSStringFromClass([obj class]);
82     name = [self labelForKey:name];
83
84     if (![name hasPrefix:@"sogod"]) {
85       NSMutableDictionary *c;
86       NSString *url;
87       
88       url = [obj baseURLInContext:[self context]];
89       if (![url hasSuffix:@"/"])
90         url = [url stringByAppendingString:@"/"];
91       
92       c = [[NSMutableDictionary alloc] initWithCapacity:2];
93       [c setObject:name forKey:@"name"];
94       [c setObject:url forKey:@"url"];
95       [navPathComponents addObject:c];
96       [c release];
97     }
98   }
99
100   [self setLastElement:[navPathComponents lastObject]];
101   return [navPathComponents autorelease];
102 }
103
104 @end /* UIxAppNavView */