/* Copyright (C) 2000-2005 SKYRIX Software AG This file is part of SOPE. SOPE 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. SOPE 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 SOPE; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "JSMenu.h" #include "JSMenuItem.h" #include #include #include "common.h" @implementation JSMenu - (id)initWithName:(NSString *)_name associations:(NSDictionary *)_config template:(WOElement *)_subs { if((self = [super initWithName:_name associations:_config template:_subs])) { self->fgColor = OWGetProperty(_config,@"fgColor"); self->bgColor = OWGetProperty(_config,@"bgColor"); self->fgColorHigh = OWGetProperty(_config,@"fgColorHigh"); self->bgColorHigh = OWGetProperty(_config,@"bgColorHigh"); self->borderColor = OWGetProperty(_config,@"borderColor"); self->borderWidth = OWGetProperty(_config,@"borderWidth"); self->fontSize = OWGetProperty(_config,@"fontSize"); self->width = OWGetProperty(_config,@"width"); self->leftPadding = OWGetProperty(_config,@"leftPadding"); self->string = OWGetProperty(_config,@"string"); self->bindAtId = OWGetProperty(_config,@"bindAtId"); self->align = OWGetProperty(_config,@"align"); self->tag = OWGetProperty(_config,@"tag"); self->template = [_subs retain]; } return self; } - (void)dealloc { [self->fgColor release]; [self->bgColor release]; [self->fgColorHigh release]; [self->bgColorHigh release]; [self->borderWidth release]; [self->fontSize release]; [self->width release]; [self->leftPadding release]; [self->string release]; [self->bindAtId release]; [self->align release]; [self->tag release]; [self->template release]; [super dealloc]; } /* handling requests */ - (id)invokeActionForRequest:(WORequest *)_req inContext:(WOContext *)_ctx { return [self->template invokeActionForRequest:_req inContext:_ctx]; } /* generate response */ - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { WOComponent *comp; NSString *tmp; NSString *eid; // [_ctx elementID] WEClientCapabilities *ccaps; BOOL ie, ns; if ([_ctx isRenderingDisabled]) { [self->template appendToResponse:_response inContext:_ctx]; return; } eid = [[[_ctx elementID] componentsSeparatedByString:@"."] componentsJoinedByString:@"_"]; comp = [_ctx component]; ccaps = [[_ctx request] clientCapabilities]; ie = [ccaps isJavaScriptBrowser] && [ccaps isInternetExplorer]; ns = [ccaps isJavaScriptBrowser] && [ccaps isNetscape]; [_ctx setObject:eid forKey:@"eid"]; if (!ie) { return; [_response appendContentString:@"["]; [self->template appendToResponse:_response inContext:_ctx]; [_response appendContentString:@"]"]; return; } if (ie) { if ([_ctx objectForKey:@"jsmenu_included"] == nil) { [_ctx setObject:@"done" forKey:@"jsmenu_included"]; tmp = [[NSString alloc] initWithFormat: @"\n", [self->fontSize stringValueInComponent:comp], [self->width stringValueInComponent:comp], [self->leftPadding stringValueInComponent:comp], [self->bgColor stringValueInComponent:comp], [self->fgColor stringValueInComponent:comp], [self->align stringValueInComponent:comp], [self->fontSize stringValueInComponent:comp], [self->width stringValueInComponent:comp], [self->leftPadding stringValueInComponent:comp], [self->bgColorHigh stringValueInComponent:comp], [self->fgColorHigh stringValueInComponent:comp], [self->align stringValueInComponent:comp]]; [_response appendContentString:tmp]; [tmp release]; tmp = [[NSString alloc] initWithFormat: @"\n", [self->width stringValueInComponent:comp], [self->width stringValueInComponent:comp]]; [_response appendContentString:tmp]; [tmp release]; } tmp = [[NSString alloc] initWithFormat: @"
", eid, eid, [self->width stringValueInComponent:comp], [self->bgColor stringValueInComponent:comp], [self->borderWidth stringValueInComponent:comp], [self->borderColor stringValueInComponent:comp]]; [_response appendContentString:tmp]; [tmp release]; [self->template appendToResponse:_response inContext:_ctx]; [_response appendContentString:@"
"]; #if 0 if ([self->tag stringValueInComponent:comp] != nil) tmp = [[NSString alloc] initWithFormat: @"", eid, eid, eid, eid, [self->tag stringValueInComponent:comp], eid]; else #endif tmp = [[NSString alloc] initWithFormat: @"", eid, eid, eid, eid, eid]; [_response appendContentString:tmp]; [tmp release]; } #if 0 if (ns) { if ([_ctx objectForKey:@"jsmenu_included"] == nil) { tmp = [[NSString alloc] initWithFormat: @"\n" @"\n", eid]; [_response appendContentString:tmp]; [tmp release]; } tmp = [[NSString alloc] initWithFormat: @"\n" @"" @"M", eid]; [_response appendContentString:tmp]; [tmp release]; [_ctx setObject:@"done" forKey:@"jsmenu_included"]; } #endif } @end /* JSMenu */