]> err.no Git - scalable-opengroupware.org/blob - SOGo/UI/Scheduler/UIxCalWeekPrintview.m
fixes for SOGo bug #1070
[scalable-opengroupware.org] / SOGo / UI / Scheduler / UIxCalWeekPrintview.m
1 /*
2  Copyright (C) 2004 SKYRIX Software AG
3  
4  This file is part of OpenGroupware.org.
5  
6  OGo is free software; you can redistribute it and/or modify it under
7  the terms of the GNU Lesser General Public License as published by the
8  Free Software Foundation; either version 2, or (at your option) any
9  later version.
10  
11  OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12  WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14  License for more details.
15  
16  You should have received a copy of the GNU Lesser General Public
17  License along with OGo; see the file COPYING.  If not, write to the
18  Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19  02111-1307, USA.
20  */
21 // $Id$
22
23 #include "UIxCalWeekOverview.h"
24
25 @interface UIxCalWeekPrintview : UIxCalWeekOverview
26 {
27 }
28
29 @end
30
31 #include "common.h"
32
33 @implementation UIxCalWeekPrintview
34
35 - (NSString *)shortTextForApt {
36   NSCalendarDate  *startDate, *endDate;
37   NSMutableString *aptDescr;
38   NSString        *s;
39   BOOL            isMyApt;
40   BOOL            spansRange;
41   id              apt;
42   
43   apt        = [self appointment];
44   isMyApt    = [self isMyApt];
45   spansRange = NO;
46   startDate  = [apt valueForKey:@"startDate"];
47   [startDate setTimeZone:[self viewTimeZone]];
48   endDate    = [apt valueForKey:@"endDate"];
49   if(endDate != nil) {
50     [endDate setTimeZone:[self viewTimeZone]];
51     spansRange = ![endDate isEqualToDate:startDate];
52   }
53   aptDescr = [[NSMutableString alloc] init];
54   [aptDescr appendFormat:@"<span class=\"%@\">%02i:%02i",
55                            isMyApt ? @"weekprintview_apt_time" :
56                                      @"weekprintview_apt_time_other",
57                            [startDate hourOfDay],
58                            [startDate minuteOfHour]];
59   if(spansRange) {
60     [aptDescr appendFormat:@" - %02i:%02i",
61                              [endDate hourOfDay],
62                              [endDate minuteOfHour]];
63   }
64   [aptDescr appendFormat:@"</span>,"];
65   if(!isMyApt)
66     [aptDescr appendFormat:@"<span class=\"%@\">", [self aptStyle]];
67   s = [apt valueForKey:@"title"];
68   if(s) {
69     [aptDescr appendFormat:@"<br />%@", s];
70   }
71   s = [apt valueForKey:@"location"];
72   if(s) {
73     [aptDescr appendFormat:@"<br />%@", s];
74   }
75   if(!isMyApt)
76     [aptDescr appendString:@"</span>"];
77   return [aptDescr autorelease];
78 }
79
80 - (NSString *)title {
81   NSMutableString *title;
82   NSCalendarDate *date;
83   
84   date  = [self startDate];
85   title = [[NSMutableString alloc] init];
86   [title appendFormat:@"%@ %d",
87     [self localizedNameForMonthOfYear:[date monthOfYear]],
88     [date yearOfCommonEra]];
89   if([date monthOfYear] != [[self endDate] monthOfYear]) {        
90     [title appendFormat:@" / %@ %d",
91       [self localizedNameForMonthOfYear:[[self endDate] monthOfYear]],
92       [[self endDate] yearOfCommonEra]];
93   }
94   [title appendFormat:@", %@ %d",
95     [self labelForKey:@"Week"],
96     [date weekOfYear]];
97   return [title autorelease];
98 }
99
100 /* style sheet */
101
102 - (NSString *)titleStyle {
103   if([self->currentDay isToday])
104     return @"weekoverview_title_hilite";
105   return @"weekoverview_title";
106 }
107
108 - (NSString *)contentStyle {
109   if([self->currentDay isToday])
110     return @"weekoverview_content_hilite";
111   return @"weekoverview_content";
112 }
113
114 - (NSString *)aptStyle {
115   if (![self isMyApt])
116     return @"weekprintview_apt_other";
117   return nil;
118 }
119
120 @end