/* Copyright (C) 2000-2005 SKYRIX Software AG This file is part of OpenGroupware.org. OGo is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. OGo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with OGo; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include /* SkyObjectValue TODO: where is it used? describe what it does. */ @class WOAssociation; @interface SkyObjectValue : WODynamicElement { @protected // WODynamicElement: extraAttributes // WODynamicElement: otherTagString WOAssociation *object; // object which will be tested whether archived or not WOAssociation *value; // displayed value WOAssociation *action; // for Hyperlinks WOAssociation *bold; // display non archived as bold /* value value */ } @end /* SkyObjectValue */ #include #include #include "common.h" @implementation SkyObjectValue - (id)initWithName:(NSString *)_name associations:(NSDictionary *)_config template:(WOElement *)_c { if ((self = [super initWithName:_name associations:_config template:_c])) { self->object = OWGetProperty(_config, @"object"); self->value = OWGetProperty(_config, @"value"); self->action = OWGetProperty(_config, @"action"); self->bold = OWGetProperty(_config, @"bold"); if (self->object == nil) { [self warnWithFormat: @"missing 'object' association in element %@ !", _name]; } if (self->value == nil) { [self warnWithFormat: @"missing 'value' association in element %@ !", _name]; } } return self; } - (void)dealloc { [self->value release]; [self->object release]; [self->action release]; [self->bold release]; [super dealloc]; } /* processing requests */ - (id)invokeActionForRequest:(WORequest *)_rq inContext:(WOContext *)_ctx { if (self->action != nil) return [self->action valueInComponent:[_ctx component]]; return nil; } /* generating response */ - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { WOComponent *c; NSString *t = nil; NSString *v; id cfg; BOOL isArchived; BOOL b; BOOL isLink; c = [_ctx component]; v = [self->value stringValueInComponent:c]; if (![v isNotEmpty]) return; cfg = [c config]; b = (self->bold != nil) ? [[self->bold valueInComponent:c] boolValue] : NO; isArchived = [[[self->object valueInComponent:c] valueForKey:@"dbStatus"] isEqualToString:@"archived"]; isLink = ((!isArchived) && (self->action != nil)) ? YES : NO; /* open font tag */ [_response appendContentString:@""]; if (isLink) { [_response appendContentString:@""]; } if (b) [_response appendContentString:@""]; [_response appendContentString:v]; if (b) [_response appendContentString:@""]; if (isLink) [_response appendContentString:@""]; [_response appendContentString:@""]; } /* description */ - (NSString *)associationDescription { NSMutableString *str; str = [NSMutableString stringWithCapacity:64]; if (self->object) [str appendFormat:@" object=%@", self->object]; if (self->value) [str appendFormat:@" value=%@", self->value]; return str; } @end /* SkyObjectValue */