From 81e49c94e78cbcc131e6aa0bde420d4b6792360a Mon Sep 17 00:00:00 2001 From: helge Date: Tue, 23 Nov 2004 22:31:55 +0000 Subject: [PATCH] added support for href and direct actions in tab items git-svn-id: http://svn.opengroupware.org/SOPE/trunk@409 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-appserver/WEExtensions/ChangeLog | 4 +- sope-appserver/WEExtensions/Version | 2 +- sope-appserver/WEExtensions/WETabItem.m | 81 +++++++++++++++++-------- sope-appserver/WEExtensions/WETabView.h | 5 +- 4 files changed, 64 insertions(+), 28 deletions(-) diff --git a/sope-appserver/WEExtensions/ChangeLog b/sope-appserver/WEExtensions/ChangeLog index 8b998d78..b0cfd531 100644 --- a/sope-appserver/WEExtensions/ChangeLog +++ b/sope-appserver/WEExtensions/ChangeLog @@ -1,5 +1,7 @@ 2004-11-23 Helge Hess - + + * WETabItem.[hm]: added support for href and direct actions (v4.5.64) + * v4.5.63 * removed WEClientCapabilities.h (lives in NGObjWeb for quite some time now) diff --git a/sope-appserver/WEExtensions/Version b/sope-appserver/WEExtensions/Version index 645b0033..c41a410a 100644 --- a/sope-appserver/WEExtensions/Version +++ b/sope-appserver/WEExtensions/Version @@ -1,3 +1,3 @@ # version file -SUBMINOR_VERSION:=63 +SUBMINOR_VERSION:=64 diff --git a/sope-appserver/WEExtensions/WETabItem.m b/sope-appserver/WEExtensions/WETabItem.m index 06a899d1..fbd499c6 100644 --- a/sope-appserver/WEExtensions/WETabItem.m +++ b/sope-appserver/WEExtensions/WETabItem.m @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "WETabView.h" #include "common.h" @@ -75,7 +74,11 @@ static NSString *retStrForInt(int i) { self->label = WOExtGetProperty(_config, @"label"); self->action = WOExtGetProperty(_config, @"action"); self->isScript = WOExtGetProperty(_config, @"isScript"); - + + self->href = WOExtGetProperty(_config, @"href"); + self->directActionName = WOExtGetProperty(_config, @"directActionName"); + self->actionClass = WOExtGetProperty(_config, @"actionClass"); + self->tabIcon = WOExtGetProperty(_config, @"tabIcon"); self->leftTabIcon = WOExtGetProperty(_config, @"leftTabIcon"); self->selectedTabIcon = WOExtGetProperty(_config, @"selectedTabIcon"); @@ -92,24 +95,23 @@ static NSString *retStrForInt(int i) { } - (void)dealloc { - [self->action release]; - [self->label release]; - [self->icon release]; - [self->key release]; - [self->isScript release]; - [self->template release]; - - [self->leftTabIcon release]; - [self->selectedTabIcon release]; - [self->tabIcon release]; - - [self->asBackground release]; - [self->width release]; - [self->height release]; - - [self->activeBgColor release]; - [self->inactiveBgColor release]; - + [self->href release]; + [self->directActionName release]; + [self->actionClass release]; + [self->action release]; + [self->label release]; + [self->icon release]; + [self->key release]; + [self->isScript release]; + [self->template release]; + [self->leftTabIcon release]; + [self->selectedTabIcon release]; + [self->tabIcon release]; + [self->asBackground release]; + [self->width release]; + [self->height release]; + [self->activeBgColor release]; + [self->inactiveBgColor release]; [super dealloc]; } @@ -194,6 +196,35 @@ static NSString *retStrForInt(int i) { return result; } +/* URLs */ + +- (NSString *)urlForTabItemInContext:(WOContext *)_ctx { + if (self->href != nil) + return [self->href stringValueInComponent:[_ctx component]]; + + if (self->directActionName != nil || self->actionClass != nil) { + NSDictionary *qd = nil; + NSString *daClass = nil; + NSString *daName = nil; + + daClass = [self->actionClass stringValueInComponent:[_ctx component]]; + daName = [self->directActionName stringValueInComponent:[_ctx component]]; + + if (daClass != nil) { + if (daName != nil) { + if (![daClass isEqualToString:@"DirectAction"]) + daName = [NSString stringWithFormat:@"%@/%@", daClass, daName]; + } + else + daName = daClass; + } + + return [_ctx directActionURLForActionNamed:daName queryDictionary:qd]; + } + + return [_ctx componentActionURL]; +} + /* info collection */ - (void)_collectInContext:(WOContext *)_ctx key:(NSString *)k { @@ -220,11 +251,11 @@ static NSString *retStrForInt(int i) { info = [[WETabItemInfo alloc] init]; info->key = [k copy]; - info->label = [[self->label stringValueInComponent:cmp] copy]; - info->icon = [[self->icon stringValueInComponent:cmp] copy]; - info->uri = [[_ctx componentActionURL] copy]; - info->isScript = [self->isScript boolValueInComponent:cmp]; - info->tabIcon = [[self->tabIcon stringValueInComponent:cmp] copy]; + info->uri = [[self urlForTabItemInContext:_ctx] copy]; + info->label = [[self->label stringValueInComponent:cmp] copy]; + info->icon = [[self->icon stringValueInComponent:cmp] copy]; + info->isScript = [self->isScript boolValueInComponent:cmp]; + info->tabIcon = [[self->tabIcon stringValueInComponent:cmp] copy]; info->leftIcon = [[self->leftTabIcon stringValueInComponent:cmp] copy]; info->selIcon = [[self->selectedTabIcon stringValueInComponent:cmp] copy]; diff --git a/sope-appserver/WEExtensions/WETabView.h b/sope-appserver/WEExtensions/WETabView.h index c12ecc3d..0dc57e6d 100644 --- a/sope-appserver/WEExtensions/WETabView.h +++ b/sope-appserver/WEExtensions/WETabView.h @@ -78,7 +78,10 @@ WOAssociation *label; WOAssociation *action; WOAssociation *isScript; - + WOAssociation *href; + WOAssociation *actionClass; + WOAssociation *directActionName; + /* config: */ WOAssociation *tabIcon; WOAssociation *leftTabIcon; -- 2.39.5