]> err.no Git - scalable-opengroupware.org/commitdiff
Work in progress - pushed everything from query strings to query parameter dictionari...
authorznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Fri, 18 Jun 2004 10:16:51 +0000 (10:16 +0000)
committerznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Fri, 18 Jun 2004 10:16:51 +0000 (10:16 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@48 d1b88da0-ebda-0310-925b-ed51d893ca5b

14 files changed:
ZideStore/UI-X/Common/GNUmakefile
ZideStore/UI-X/Common/OGoComponent.h [new file with mode: 0644]
ZideStore/UI-X/Common/OGoComponent.m [new file with mode: 0644]
ZideStore/UI-X/Common/bundle-info.plist
ZideStore/UI-X/Scheduler/OGoCalBackForthNavView.m
ZideStore/UI-X/Scheduler/OGoCalBackForthNavView.wox
ZideStore/UI-X/Scheduler/OGoCalMonthView.m
ZideStore/UI-X/Scheduler/OGoCalSelectTab.m
ZideStore/UI-X/Scheduler/OGoCalSelectTab.wox
ZideStore/UI-X/Scheduler/OGoCalView.h
ZideStore/UI-X/Scheduler/OGoCalView.m
ZideStore/UI-X/Scheduler/OGoCalWeekOverview.wox
ZideStore/UI-X/Scheduler/OGoCalWeekView.h
ZideStore/UI-X/Scheduler/OGoCalWeekView.m

index 167a858a3dd47f8e45313f7f3f79a724d139a2e4..ce11ad9ae683accae1417fba7c77cf6cfc329445 100644 (file)
@@ -10,6 +10,7 @@ CommonUI_PRINCIPAL_CLASS = CommonUIProduct
 
 CommonUI_OBJC_FILES = \
        CommonUIProduct.m       \
+       OGoComponent.m \
        OGoPageFrame.m          \
        OGoAppFrame.m           \
        OGoAppHeader.m          \
@@ -21,6 +22,11 @@ CommonUI_OBJC_FILES = \
        UIxTabView.m \
        UIxTabItem.m \
 
+
+CommonUI_HEADER_FILES = \
+       OGoComponent.h \
+
+
 CommonUI_RESOURCE_FILES += \
        Version                 \
        product.plist           \
diff --git a/ZideStore/UI-X/Common/OGoComponent.h b/ZideStore/UI-X/Common/OGoComponent.h
new file mode 100644 (file)
index 0000000..86795fd
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+  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_ */
diff --git a/ZideStore/UI-X/Common/OGoComponent.m b/ZideStore/UI-X/Common/OGoComponent.m
new file mode 100644 (file)
index 0000000..e6b4e62
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+  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
index 13cf8e52d74611b1133c1d0042d2aadfeac89592..2ccc1b8cd80bb0432984482a100ac7aaae10b07b 100644 (file)
@@ -13,6 +13,7 @@
     
     classes = (
       { name = CommonUIProduct;       },
+      { name = OGoComponent;          },
       { name = OGoPageFrame;          },
       { name = OGoWinClose;           },
       { name = OGoAppNavView;         },
index 1b95fe14748745604692e08bb226b178d7c6dfe4..56edc0511aba55af69e7100023dfddb47ccf5368 100644 (file)
 
 #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
 {
index 01d672e8ad36e8f2e3a2469f71abfc292e6d6ed7..7c86e8c26cd3401f2757c8a097b3cde64ee32f81 100644 (file)
@@ -8,13 +8,13 @@
  >
     <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
index eb6ba7e197bc976316d5a176a57264ecadc071f3..3530b839f6c42124146f15cbd7ab454742ac38bf 100644 (file)
@@ -5,22 +5,15 @@
 
 @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];
 }
 
index f06d3f3a1e162a129afecefe3e1c9ade13142d07..a2bcb9fc5660c36c46cdc81e1f15e277a574075a 100644 (file)
 // $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"];
 }
 
 
index 532232e7d7257dd66c2e0d3a5d9c62b94cdabb3c..98ae502cc0c5f46f7c1f0438986563887f5e9efb 100644 (file)
              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>
index 6468c7f76c4cc5a9e8691b68b265f0810e4abad2..37783a76b696c3acde0ab3ee25c4207ed5f5c654 100644 (file)
@@ -3,12 +3,12 @@
 #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;
@@ -23,8 +23,6 @@
 
 - (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;
 
index d08551c6e9270d2ce8e3e074501ca110659a5f70..1928ac0e7d6367d9e4fbb8ffb43c0a535bfd511b 100644 (file)
@@ -69,7 +69,8 @@
 }
 
 - (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 */
index 83a26a012b857fdd152816869c890742a014de50..e69e697fba52f6c48bb70ba2183a541284b1b1f6 100644 (file)
@@ -29,7 +29,7 @@
     <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>
@@ -41,7 +41,7 @@
   <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>
@@ -96,6 +96,8 @@
   </td>
   </tr>
   </table>
+  <hr />
+  <var:string value="thisWeekQueryParameters" />
   <!--
   <hr/>
     
index 480050987575664891c31c72718d6203d08730de..c01f95078ffe422b3ea075c4916653885650ac04 100644 (file)
@@ -9,11 +9,12 @@
 {
 }
 
-/* URLs */
-
-- (NSString *)prevWeekURL;
-- (NSString *)nextWeekURL;
+/* Query Parameters */
 
+- (NSDictionary *)prevWeekQueryParameters;
+- (NSDictionary *)thisWeekQueryParameters;
+- (NSDictionary *)nextWeekQueryParameters;
+    
 @end
 
 #endif /* __ZideStoreUI_OGoCalWeekView_H__ */
index 8ccdcd037309e644fe3d80d445c6abc2483f6be1..c3ac9f6ee54c01a44c0d4990f66728628c3b40cd 100644 (file)
@@ -6,15 +6,7 @@
 @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 */