2008-01-14 14:57:28 +01:00
|
|
|
/* UIxRecurrenceEditor.m - this file is part of SOGo
|
|
|
|
*
|
2015-05-20 17:11:01 +02:00
|
|
|
* Copyright (C) 2015 Inverse inc.
|
2008-01-14 14:57:28 +01:00
|
|
|
*
|
|
|
|
* This file is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This file 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/NSArray.h>
|
2015-05-20 17:11:01 +02:00
|
|
|
#import <Foundation/NSDictionary.h>
|
2008-01-14 14:57:28 +01:00
|
|
|
#import <Foundation/NSString.h>
|
2013-01-22 16:58:11 +01:00
|
|
|
#import <Foundation/NSUserDefaults.h> /* for locale string constants */
|
2008-01-14 14:57:28 +01:00
|
|
|
|
|
|
|
#import <Common/UIxPageFrame.h>
|
|
|
|
|
2015-05-20 17:11:01 +02:00
|
|
|
#import <SOPE/NGCards/iCalRecurrenceRule.h>
|
|
|
|
|
2008-01-14 14:57:28 +01:00
|
|
|
#import "UIxRecurrenceEditor.h"
|
|
|
|
|
|
|
|
@implementation UIxRecurrenceEditor
|
|
|
|
|
2013-01-22 16:58:11 +01:00
|
|
|
- (NSArray *) shortWeekDaysList
|
|
|
|
{
|
|
|
|
static NSArray *shortWeekDaysList = nil;
|
|
|
|
|
|
|
|
if (!shortWeekDaysList)
|
|
|
|
{
|
|
|
|
shortWeekDaysList = [locale objectForKey: NSShortWeekDayNameArray];
|
|
|
|
[shortWeekDaysList retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return shortWeekDaysList;
|
|
|
|
}
|
|
|
|
|
2008-01-14 14:57:28 +01:00
|
|
|
- (NSArray *) monthlyRepeatList
|
|
|
|
{
|
|
|
|
static NSArray *monthlyRepeatList = nil;
|
|
|
|
|
|
|
|
if (!monthlyRepeatList)
|
|
|
|
{
|
2008-01-15 22:45:48 +01:00
|
|
|
monthlyRepeatList = [NSArray arrayWithObjects: @"First", @"Second", @"Third",
|
2009-03-24 21:10:46 +01:00
|
|
|
@"Fourth", @"Fift", @"Last", nil];
|
2008-01-14 14:57:28 +01:00
|
|
|
[monthlyRepeatList retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return monthlyRepeatList;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) monthlyDayList
|
|
|
|
{
|
2013-01-22 16:58:11 +01:00
|
|
|
static NSMutableArray *monthlyDayList = nil;
|
2008-01-14 14:57:28 +01:00
|
|
|
|
|
|
|
if (!monthlyDayList)
|
|
|
|
{
|
2013-01-22 16:58:11 +01:00
|
|
|
monthlyDayList = [NSMutableArray arrayWithArray: [locale objectForKey: NSWeekDayNameArray]];
|
2015-05-20 17:11:01 +02:00
|
|
|
[monthlyDayList addObject: [self labelForKey: @"DayOfTheMonth"]];
|
2008-01-14 14:57:28 +01:00
|
|
|
[monthlyDayList retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return monthlyDayList;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) yearlyMonthList
|
|
|
|
{
|
|
|
|
static NSArray *yearlyMonthList = nil;
|
|
|
|
|
|
|
|
if (!yearlyMonthList)
|
|
|
|
{
|
2015-05-20 17:11:01 +02:00
|
|
|
yearlyMonthList = [locale objectForKey: NSShortMonthNameArray];
|
2008-01-14 14:57:28 +01:00
|
|
|
[yearlyMonthList retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return yearlyMonthList;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) yearlyDayList
|
|
|
|
{
|
|
|
|
static NSArray *yearlyDayList = nil;
|
|
|
|
|
|
|
|
if (!yearlyDayList)
|
|
|
|
{
|
2013-01-22 16:58:11 +01:00
|
|
|
yearlyDayList = [locale objectForKey: NSWeekDayNameArray];
|
2008-01-14 14:57:28 +01:00
|
|
|
[yearlyDayList retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return yearlyDayList;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Items used to specify what kind of recurrence we want
|
|
|
|
//
|
|
|
|
- (NSArray *) repeatList
|
|
|
|
{
|
2015-05-20 17:11:01 +02:00
|
|
|
static NSArray *repeatItems = nil;
|
2008-01-14 14:57:28 +01:00
|
|
|
|
2015-05-20 17:11:01 +02:00
|
|
|
if (!repeatItems)
|
2008-01-14 14:57:28 +01:00
|
|
|
{
|
2015-05-20 17:11:01 +02:00
|
|
|
repeatItems = [NSArray arrayWithObjects: @"daily",
|
|
|
|
@"weekly",
|
|
|
|
@"bi-weekly",
|
|
|
|
@"every_weekday",
|
|
|
|
@"monthly",
|
|
|
|
@"yearly",
|
|
|
|
nil];
|
|
|
|
[repeatItems retain];
|
2008-01-14 14:57:28 +01:00
|
|
|
}
|
|
|
|
|
2015-05-20 17:11:01 +02:00
|
|
|
return repeatItems;
|
2008-01-14 14:57:28 +01:00
|
|
|
}
|
|
|
|
|
2015-05-20 17:11:01 +02:00
|
|
|
- (NSString *) itemRepeatText
|
|
|
|
{
|
|
|
|
return [self labelForKey: [NSString stringWithFormat: @"repeat_%@", [item uppercaseString]]];
|
|
|
|
}
|
2008-01-14 14:57:28 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Accessors
|
|
|
|
//
|
|
|
|
- (void) setItem: (NSString *) theItem
|
|
|
|
{
|
|
|
|
item = theItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) item
|
|
|
|
{
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2008-01-15 22:45:48 +01:00
|
|
|
- (NSString *) itemText
|
2008-01-14 14:57:28 +01:00
|
|
|
{
|
|
|
|
NSString *text;
|
|
|
|
|
2008-01-15 22:45:48 +01:00
|
|
|
text = [self labelForKey: item];
|
2008-01-14 14:57:28 +01:00
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2013-01-22 16:58:11 +01:00
|
|
|
- (NSString *) idForWeekDay
|
|
|
|
{
|
|
|
|
static NSArray *shortWeekDaysList = nil;
|
|
|
|
NSString *id;
|
|
|
|
|
|
|
|
if (!shortWeekDaysList)
|
|
|
|
{
|
|
|
|
shortWeekDaysList = [locale objectForKey: NSShortWeekDayNameArray];
|
|
|
|
[shortWeekDaysList retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
id = [NSString stringWithFormat: @"weekDay%i", [shortWeekDaysList indexOfObject: item]];
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) labelForWeekDay
|
|
|
|
{
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2015-05-20 17:11:01 +02:00
|
|
|
- (NSString *) valueForWeekDay
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
i = [[self shortWeekDaysList] indexOfObject: item];
|
|
|
|
|
|
|
|
return iCalWeekDayString[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) valueForMonthlyRepeat
|
|
|
|
{
|
|
|
|
static NSArray *monthlyRepeatValues = nil;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (!monthlyRepeatValues)
|
|
|
|
{
|
|
|
|
monthlyRepeatValues = [NSArray arrayWithObjects: @"1", @"2", @"3",
|
|
|
|
@"4", @"5", @"-1", nil];
|
|
|
|
[monthlyRepeatValues retain];
|
|
|
|
}
|
|
|
|
i = [[self monthlyRepeatList] indexOfObject: item];
|
|
|
|
|
|
|
|
return [monthlyRepeatValues objectAtIndex: i];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) valueForMonthlyDay
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
i = [[self monthlyDayList] indexOfObject: item];
|
|
|
|
if (i % 7 != i)
|
|
|
|
return @"";
|
|
|
|
else
|
|
|
|
return iCalWeekDayString[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (unsigned int) valueForYearlyMonth
|
|
|
|
{
|
|
|
|
return [[self yearlyMonthList] indexOfObject: item] + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) valueForYearlyDay
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
i = [[self yearlyDayList] indexOfObject: item];
|
|
|
|
|
|
|
|
return iCalWeekDayString[i];
|
|
|
|
}
|
|
|
|
|
2008-01-14 14:57:28 +01:00
|
|
|
@end
|