CommonUI_OBJC_FILES = \
CommonUIProduct.m \
+ OGoComponent.m \
OGoPageFrame.m \
OGoAppFrame.m \
OGoAppHeader.m \
UIxTabView.m \
UIxTabItem.m \
+
+CommonUI_HEADER_FILES = \
+ OGoComponent.h \
+
+
CommonUI_RESOURCE_FILES += \
Version \
product.plist \
--- /dev/null
+/*
+ Copyright (C) 2000-2004 SKYRIX Software AG
+
+ This file is part of OGo
+
+ 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.
+*/
+// $Id$
+
+
+#ifndef __OGoComponent_H_
+#define __OGoComponent_H_
+
+#include <NGObjWeb/SoComponent.h>
+
+
+@interface OGoComponent : SoComponent
+{
+ NSMutableDictionary *queryParameters;
+}
+
+- (NSString *)queryParameterForKey:(NSString *)_key;
+- (NSDictionary *)queryParameters;
+
+/* use this to set permanent query parameters */
+- (void)setQueryParameter:(NSString *)_param forKey:(NSString *)_key;
+
+@end
+
+#endif /* __OGoComponent_H_ */
--- /dev/null
+/*
+ Copyright (C) 2000-2004 SKYRIX Software AG
+
+ This file is part of OGo
+
+ 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.
+*/
+// $Id$
+
+
+#include "OGoComponent.h"
+#include <Foundation/Foundation.h>
+#include <NGObjWeb/NGObjWeb.h>
+#include <NGExtensions/NGExtensions.h>
+
+
+@interface OGoComponent (PrivateAPI)
+- (void)_parseQueryString:(NSString *)_s;
+@end
+
+
+@implementation OGoComponent
+
+- (id)init {
+ if ((self = [super init])) {
+ self->queryParameters = [[NSMutableDictionary alloc] init];
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [self->queryParameters release];
+ [super dealloc];
+}
+
+
+- (void)awake {
+ WORequest *req;
+ NSString *uri;
+ NSRange r;
+
+ [super awake];
+
+ req = [[self context] request];
+ uri = [req uri];
+ r = [uri rangeOfString:@"?"];
+ if(r.length > 0) {
+ NSString *qs;
+
+ qs = [uri substringFromIndex:(r.location + r.length)];
+ [self->queryParameters removeAllObjects];
+ [self _parseQueryString:qs];
+ }
+}
+
+- (void)_parseQueryString:(NSString *)_s {
+ NSEnumerator *e;
+ NSString *part;
+
+ e = [[_s componentsSeparatedByString:@"&"] objectEnumerator];
+ while ((part = [e nextObject])) {
+ NSRange r;
+ NSString *key, *value;
+
+ r = [part rangeOfString:@"="];
+ if (r.length == 0) {
+ /* missing value of query parameter */
+ key = [part stringByUnescapingURL];
+ value = @"1";
+ }
+ else {
+ key = [[part substringToIndex:r.location] stringByUnescapingURL];
+ value = [[part substringFromIndex:(r.location + r.length)]
+ stringByUnescapingURL];
+ }
+ [self->queryParameters setObject:value forKey:key];
+ }
+}
+
+- (NSString *)queryParameterForKey:(NSString *)_key {
+ return [self->queryParameters objectForKey:_key];
+}
+
+- (void)setQueryParameter:(NSString *)_param forKey:(NSString *)_key {
+ if(_key == nil)
+ return;
+
+ if(_param != nil)
+ [self->queryParameters setObject:_param forKey:_key];
+ else
+ [self->queryParameters removeObjectForKey:_key];
+}
+
+- (NSDictionary *)queryParameters {
+ return self->queryParameters;
+}
+
+@end
classes = (
{ name = CommonUIProduct; },
+ { name = OGoComponent; },
{ name = OGoPageFrame; },
{ name = OGoWinClose; },
{ name = OGoAppNavView; },
#include <NGObjWeb/NGObjWeb.h>
+/*
+ Associations:
+
+ methodName -> maps to href
+ prevQueryParameters -> queryDictionary
+ currentQueryParameters -> queryDictionary
+ nextQueryParameters -> queryDictionary
+ label -> user presentable name to display for "this"
+ */
@interface OGoCalBackForthNavView : WOComponent
{
>
<tr>
<td align="right" valign="middle">
- <a var:href="^prevURL"><img rsrc:src="previous_week.gif" alt="previous" border="0"/></a>
+ <a var:href="^methodName" var:queryDictionary="^prevQueryParameters"><img rsrc:src="previous_week.gif" alt="previous" border="0"/></a>
</td>
<td align="right" valign="middle" class="button_auto_env">
- <a var:href="^currentURL" class="button_auto"><var:string value="^label" escapeHTML="NO" /></a>
+ <a var:href="^methodName" var:queryDictionary="^currentQueryParameters" class="button_auto"><var:string value="^label" escapeHTML="NO" /></a>
</td>
<td align="right" valign="middle">
- <a var:href="^nextURL"><img rsrc:src="next_week.gif" alt="next" border="0"/></a>
+ <a var:href="^methodName" var:queryDictionary="^nextQueryParameters"><img rsrc:src="next_week.gif" alt="next" border="0"/></a>
</td>
</tr>
</table>
\ No newline at end of file
@implementation OGoCalMonthView
-// TODO: look how to properly calculate month range!
-
- (NSCalendarDate *)startDate {
- // TODO: copy of the startdate method
- NSCalendarDate *startDate;
- NSString *dateString;
-
- dateString = [[[self context] request] formValueForKey:@"startDate"];
- startDate = dateString
- ? [self dateForDateString:dateString]
- : [[NSCalendarDate date] mondayOfWeek];
-
- return startDate;
+ return [[super startDate] firstDayOfMonth];
}
+
- (NSCalendarDate *)endDate {
- return [[self startDate] dateByAddingYears:0 months:0 days:31
+ NSCalendarDate *startDate;
+
+ startDate = [self startDate];
+ return [startDate dateByAddingYears:0 months:0 days:[startDate numberOfDaysInMonth]
hours:0 minutes:0 seconds:0];
}
// $Id$
+#include <CommonUI/OGoComponent.h>
#include <NGObjWeb/NGObjWeb.h>
#include <NGExtensions/NGExtensions.h>
-@interface OGoCalSelectTab : WOComponent
+@interface OGoCalSelectTab : OGoComponent
{
NSString *selection;
NSCalendarDate *currentDate;
}
-- (BOOL)isCurrentDateInSameWeek;
-- (NSString *)completedLinkForOverview:(NSString *)_overview;
+- (NSString *)completeHrefForMethod:(NSString *)_method;
@end
/* labels */
-- (BOOL)isCurrentDateInSameWeek {
- return [self->currentDate isDateInSameWeek:[NSCalendarDate date]];
-}
-
- (NSString *)dayLabel {
- NSCalendarDate *date;
-
- date = self->currentDate;
-
- if(! [[self selection] isEqualToString:@"day"]) {
-#if 0
- if(! [self isCurrentDateInSameWeek])
-#endif
- date = [date mondayOfWeek];
- }
-
- return [date descriptionWithCalendarFormat:@"%d"];
+ return [self->currentDate descriptionWithCalendarFormat:@"%d"];
}
- (NSString *)weekLabel {
/* hrefs */
-- (NSString *)completedLinkForOverview:(NSString *)_overview {
- NSString *dateString;
+- (NSString *)completeHrefForMethod:(NSString *)_method {
+ NSDictionary *qp;
+ NSString *qs;
+
+ qp = [self queryParameters];
+ if([qp count] == 0)
+ return _method;
- dateString = [[[self context] request] formValueForKey:@"startDate"];
- if(dateString)
- return [_overview stringByAppendingFormat:@"?startDate=%@", dateString];
- return _overview;
+ qs = [[self context] queryStringFromDictionary:qp];
+ return [_method stringByAppendingFormat:@"?%@", qs];
}
-- (NSString *)dayoverviewLink {
- return [self completedLinkForOverview:@"dayoverview"];
+- (NSString *)daytabLink {
+ return [self completeHrefForMethod:@"dayoverview"];
}
-- (NSString *)weekoverviewLink {
- return [self completedLinkForOverview:@"weekoverview"];
+- (NSString *)weektabLink {
+ return [self completeHrefForMethod:@"weekoverview"];
}
-- (NSString *)monthoverviewLink {
- return [self completedLinkForOverview:@"monthoverview"];
+- (NSString *)monthtabLink {
+ return [self completeHrefForMethod:@"monthoverview"];
}
-- (NSString *)yearoverviewLink {
- return [self completedLinkForOverview:@"yearoverview"];
+- (NSString *)yeartabLink {
+ return [self completeHrefForMethod:@"yearoverview"];
}
const:selectedTabStyle="tab_selected"
const:bodyStyle="tabview_body"
>
- <uix:tab const:key="day" var:label="dayLabel" var:href="dayoverviewLink">
+ <uix:tab const:key="day" var:label="dayLabel" var:href="daytabLink">
<var:component-content />
</uix:tab>
- <uix:tab const:key="week" var:label="weekLabel" var:href="weekoverviewLink">
+ <uix:tab const:key="week" var:label="weekLabel" var:href="weektabLink">
<var:component-content />
</uix:tab>
- <uix:tab const:key="month" var:label="monthLabel" var:href="monthoverviewLink">
+ <uix:tab const:key="month" var:label="monthLabel" var:href="monthtabLink">
<var:component-content />
</uix:tab>
- <uix:tab const:key="year" var:label="yearLabel" var:href="yearoverviewLink">
+ <uix:tab const:key="year" var:label="yearLabel" var:href="yeartabLink">
<var:component-content />
</uix:tab>
</uix:tabview>
#ifndef __ZideStoreUI_OGoCalView_H__
#define __ZideStoreUI_OGoCalView_H__
-#include <NGObjWeb/SoComponent.h>
+#include <CommonUI/OGoComponent.h>
@class NSArray, NSCalendarDate;
@class SxAptManager, SxAptSetIdentifier;
-@interface OGoCalView : SoComponent
+@interface OGoCalView : OGoComponent
{
NSArray *appointments;
id appointment;
- (NSString *)appointmentViewURL;
- (NSString *)ownMethodName;
-- (NSString *)dateNavigationURLWithNewStartDate:(NSCalendarDate *)_newDate;
-- (NSString *)completedLinkForView:(NSString *)_view;
/* backend */
/* fetching */
+- (NSCalendarDate *)selectedDate;
- (NSCalendarDate *)startDate;
- (NSCalendarDate *)endDate;
- (NSArray *)fetchGIDs;
- (NSArray *)fetchCoreInfos;
/* date selection */
+- (NSDictionary *)queryParametersBySettingSelectedDate:(NSCalendarDate *)_date;
+- (void)setSelectedDateQueryParameter:(NSCalendarDate *)_newDate
+ inDictionary:(NSMutableDictionary *)_qp;
- (NSString *)dateStringForDate:(NSCalendarDate *)_date;
- (NSCalendarDate *)dateForDateString:(NSString *)_dateString;
}
- (NSString *)dateNavigationURLWithNewStartDate:(NSCalendarDate *)_newDate {
- return [NSString stringWithFormat:@"%@?startDate=%@",
+#warning !! REMOVE ME!!
+ return [NSString stringWithFormat:@"%@?startDate=%@",
[self ownMethodName],
[self dateStringForDate:_newDate]];
}
queryString:nil];
}
+/* date */
+
+- (NSCalendarDate *)selectedDate {
+ NSString *s;
+
+ s = [self queryParameterForKey:@"day"];
+ if(s) {
+ return [self dateForDateString:s];
+ }
+ return [NSCalendarDate date];
+}
+
/* fetching */
- (NSCalendarDate *)startDate {
- return [NSCalendarDate date];
+ return [self selectedDate];
}
- (NSCalendarDate *)endDate {
- return [[NSCalendarDate date] tomorrow];
+ return [[self startDate] tomorrow];
}
- (NSArray *)fetchGIDs {
return self->appointments;
}
+
+/* date selection & conversion */
+
+
+- (NSDictionary *)queryParametersBySettingSelectedDate:(NSCalendarDate *)_date {
+ NSMutableDictionary *qp;
+
+ qp = [[self queryParameters] mutableCopy];
+ [self setSelectedDateQueryParameter:_date inDictionary:qp];
+ return [qp autorelease];
+}
+
+- (void)setSelectedDateQueryParameter:(NSCalendarDate *)_newDate
+ inDictionary:(NSMutableDictionary *)_qp;
+{
+ if(_newDate != nil)
+ [_qp setObject:[self dateStringForDate:_newDate]
+ forKey:@"day"];
+ else
+ [_qp removeObjectForKey:@"day"];
+}
+
- (NSString *)dateStringForDate:(NSCalendarDate *)_date {
return [_date descriptionWithCalendarFormat:@"%Y%m%d"];
}
- (NSCalendarDate *)dateForDateString:(NSString *)_dateString {
return [NSCalendarDate dateWithString:_dateString calendarFormat:@"%Y%m%d"];
}
-
-- (NSString *)completedLinkForView:(NSString *)_view {
- NSString *dateString;
-
- dateString = [[[self context] request] formValueForKey:@"startDate"];
- if(dateString)
- return [_view stringByAppendingFormat:@"?startDate=%@", dateString];
- return _view;
-}
-
@end /* OGoCalView */
<tr bgcolor="#e8e8e0">
<td align="left" valign="middle" width="80%">TODO: controls</td><!-- 99% -->
<td align="right">
- <var:component className="OGoCalBackForthNavView" prevURL="prevWeekURL" currentURL="thisWeekURL" nextURL="nextWeekURL" const:label="this week" />
+ <var:component className="OGoCalBackForthNavView" methodName="ownMethodName" prevQueryParameters="prevWeekQueryParameters" currentQueryParameters="thisWeekQueryParameters" nextQueryParameters="nextWeekQueryParameters" const:label="this week" />
</td>
</tr>
</table>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2">
- <var:component className="OGoCalSelectTab" const:selection="week" currentDate="startDate">
+ <var:component className="OGoCalSelectTab" const:selection="week" currentDate="selectedDate">
<table border="0" cellpadding="4" width="100%" cellspacing="2">
<tr>
<table border='0' cellpadding='0' cellspacing='1'>
<tr>
<td class="button_auto_env" nowrap="true" valign='middle' align='center'>
- <a class="button_auto" var:href="weekprintviewLink" target="SOGoPrintView">printview</a>
+ <a class="button_auto" href="weekprintviewLink" var:queryDictionary="queryParameters" target="SOGoPrintView">printview</a>
</td>
<td class="button_auto_env" nowrap="true" valign='middle' align='center'>
- <a class="button_auto" var:href="proposalLink">proposal</a>
+ <a class="button_auto" href="proposal" var:queryDictionary="queryParameters">proposal</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
+ <hr />
+ <var:string value="thisWeekQueryParameters" />
<!--
<hr/>
{
}
-/* URLs */
-
-- (NSString *)prevWeekURL;
-- (NSString *)nextWeekURL;
+/* Query Parameters */
+- (NSDictionary *)prevWeekQueryParameters;
+- (NSDictionary *)thisWeekQueryParameters;
+- (NSDictionary *)nextWeekQueryParameters;
+
@end
#endif /* __ZideStoreUI_OGoCalWeekView_H__ */
@implementation OGoCalWeekView
- (NSCalendarDate *)startDate {
- NSCalendarDate *startDate;
- NSString *dateString;
-
- dateString = [[[self context] request] formValueForKey:@"startDate"];
- startDate = dateString
- ? [self dateForDateString:dateString]
- : [NSCalendarDate date];
-
- return [startDate mondayOfWeek];
+ return [[super startDate] mondayOfWeek];
}
- (NSCalendarDate *)endDate {
/* URLs */
-- (NSString *)prevWeekURL {
- NSCalendarDate *newWeekDate;
-
- newWeekDate = [[self startDate] dateByAddingYears:0 months:0 days:-7
- hours:0 minutes:0 seconds:0];
- return [self dateNavigationURLWithNewStartDate:newWeekDate];
-}
-
-- (NSString *)nextWeekURL {
- NSCalendarDate *newWeekDate;
-
- newWeekDate = [[self startDate] dateByAddingYears:0 months:0 days:7
- hours:0 minutes:0 seconds:0];
- return [self dateNavigationURLWithNewStartDate:newWeekDate];
-}
+- (NSDictionary *)prevWeekQueryParameters {
+ NSCalendarDate *date;
-- (NSString *)thisWeekURL {
- NSCalendarDate *newWeekDate;
-
- newWeekDate = [[NSCalendarDate date] mondayOfWeek];
- return [self dateNavigationURLWithNewStartDate:newWeekDate];
+ date = [[self startDate] dateByAddingYears:0 months:0 days:-7
+ hours:0 minutes:0 seconds:0];
+ return [self queryParametersBySettingSelectedDate:date];
}
-
-- (NSString *)weekprintviewLink {
- return [self completedLinkForView:@"weekprintview"];
+- (NSDictionary *)thisWeekQueryParameters {
+ NSCalendarDate *date;
+
+ date = [NSCalendarDate date]; /* today */
+ return [self queryParametersBySettingSelectedDate:date];
}
-- (NSString *)proposalLink {
- return [self completedLinkForView:@"proposal"];
+- (NSDictionary *)nextWeekQueryParameters {
+ NSCalendarDate *date;
+
+ date = [[self startDate] dateByAddingYears:0 months:0 days:7
+ hours:0 minutes:0 seconds:0];
+ return [self queryParametersBySettingSelectedDate:date];
}
@end /* OGoCalWeekView */