Add support for themes
This commit is contained in:
parent
da5ada9d98
commit
fd895b757b
|
@ -40,10 +40,18 @@
|
||||||
NSMutableArray *languages;
|
NSMutableArray *languages;
|
||||||
NSArray *browserLanguages;
|
NSArray *browserLanguages;
|
||||||
SOGoUser *user;
|
SOGoUser *user;
|
||||||
NSString *language;
|
NSString *language, *theme;
|
||||||
|
|
||||||
languages = [NSMutableArray array];
|
languages = [NSMutableArray array];
|
||||||
user = [self activeUser];
|
user = [self activeUser];
|
||||||
|
theme = [[self request] formValueForKey: @"theme"];
|
||||||
|
|
||||||
|
if ([theme length] > 0)
|
||||||
|
{
|
||||||
|
[languages addObject: [NSString stringWithFormat: @"theme_%@", theme]];
|
||||||
|
[self setObject: theme forKey: @"theme"];
|
||||||
|
}
|
||||||
|
|
||||||
if (!user || [[user login] isEqualToString: @"anonymous"])
|
if (!user || [[user login] isEqualToString: @"anonymous"])
|
||||||
{
|
{
|
||||||
browserLanguages = [[self request] browserLanguages];
|
browserLanguages = [[self request] browserLanguages];
|
||||||
|
@ -57,14 +65,6 @@
|
||||||
[languages addObject: language];
|
[languages addObject: language];
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (activeUser && [activeUser language])
|
|
||||||
// [languages addObject: [activeUser language]];
|
|
||||||
|
|
||||||
// if ([self hasSession])
|
|
||||||
// [languages addObjectsFromArray: [[self session] languages]];
|
|
||||||
// else
|
|
||||||
// [languages addObjectsFromArray: [[self request] browserLanguages]];
|
|
||||||
|
|
||||||
return languages;
|
return languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,10 +273,18 @@
|
||||||
- (NSString *) pageJavaScriptURL
|
- (NSString *) pageJavaScriptURL
|
||||||
{
|
{
|
||||||
WOComponent *page;
|
WOComponent *page;
|
||||||
NSString *filename;
|
NSString *theme, *filename;
|
||||||
|
|
||||||
page = [context page];
|
page = [context page];
|
||||||
filename = [NSString stringWithFormat: @"js/%@.js", NSStringFromClass([page class])];
|
theme = [context objectForKey: @"theme"];
|
||||||
|
if ([theme length])
|
||||||
|
{
|
||||||
|
filename = [NSString stringWithFormat: @"js/%@/%@.js", theme, NSStringFromClass([page class])];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filename = [NSString stringWithFormat: @"js/%@.js", NSStringFromClass([page class])];
|
||||||
|
}
|
||||||
NSLog(@"pageJavaScript => %@", filename);
|
NSLog(@"pageJavaScript => %@", filename);
|
||||||
|
|
||||||
return [self urlForResourceFilename: filename];
|
return [self urlForResourceFilename: filename];
|
||||||
|
@ -285,10 +293,19 @@
|
||||||
- (NSString *) productJavaScriptURL
|
- (NSString *) productJavaScriptURL
|
||||||
{
|
{
|
||||||
WOComponent *page;
|
WOComponent *page;
|
||||||
NSString *filename;
|
NSString *theme, *filename;
|
||||||
|
|
||||||
page = [context page];
|
page = [context page];
|
||||||
filename = [NSString stringWithFormat: @"js/%@.js", [page frameworkName]];
|
[context resourceLookupLanguages];
|
||||||
|
theme = [context objectForKey: @"theme"];
|
||||||
|
if ([theme length])
|
||||||
|
{
|
||||||
|
filename = [NSString stringWithFormat: @"js/%@/%@.js", theme, [page frameworkName]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filename = [NSString stringWithFormat: @"js/%@.js", [page frameworkName]];
|
||||||
|
}
|
||||||
NSLog(@"productJavaScript => %@", filename);
|
NSLog(@"productJavaScript => %@", filename);
|
||||||
|
|
||||||
return [self urlForResourceFilename: filename];
|
return [self urlForResourceFilename: filename];
|
||||||
|
|
|
@ -113,8 +113,9 @@
|
||||||
|
|
||||||
rm = [self pageResourceManager];
|
rm = [self pageResourceManager];
|
||||||
|
|
||||||
return [rm pathForResourceNamed: rn inFramework: fw
|
return [rm pathForResourceNamed: rn
|
||||||
languages: [[self context] resourceLookupLanguages]];
|
inFramework: fw
|
||||||
|
languages: languages];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)loadToolbarConfigFromResourceNamed:(NSString *)_name {
|
- (id)loadToolbarConfigFromResourceNamed:(NSString *)_name {
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
NSCalendarDate *_selectedDate;
|
NSCalendarDate *_selectedDate;
|
||||||
NSDictionary *locale;
|
NSDictionary *locale;
|
||||||
SOGoUserDefaults *userDefaults;
|
SOGoUserDefaults *userDefaults;
|
||||||
|
NSArray *languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray *) monthLabelKeys;
|
+ (NSArray *) monthLabelKeys;
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#import <SOGo/SOGoUser.h>
|
#import <SOGo/SOGoUser.h>
|
||||||
#import <SOGo/SOGoUserFolder.h>
|
#import <SOGo/SOGoUserFolder.h>
|
||||||
#import <SOGo/SOGoUserDefaults.h>
|
#import <SOGo/SOGoUserDefaults.h>
|
||||||
|
#import <SOGo/WOContext+SOGo.h>
|
||||||
#import <SOGo/WOResourceManager+SOGo.h>
|
#import <SOGo/WOResourceManager+SOGo.h>
|
||||||
|
|
||||||
#import "UIxJSClose.h"
|
#import "UIxJSClose.h"
|
||||||
|
@ -149,6 +150,7 @@ static SoProduct *commonProduct = nil;
|
||||||
if (!userDefaults)
|
if (!userDefaults)
|
||||||
ASSIGN (userDefaults, [SOGoSystemDefaults sharedSystemDefaults]);
|
ASSIGN (userDefaults, [SOGoSystemDefaults sharedSystemDefaults]);
|
||||||
language = [userDefaults language];
|
language = [userDefaults language];
|
||||||
|
ASSIGN (languages, [context resourceLookupLanguages]);
|
||||||
ASSIGN (locale,
|
ASSIGN (locale,
|
||||||
[[self resourceManager] localeForLanguageNamed: language]);
|
[[self resourceManager] localeForLanguageNamed: language]);
|
||||||
}
|
}
|
||||||
|
@ -536,7 +538,6 @@ static SoProduct *commonProduct = nil;
|
||||||
- (NSString *) labelForKey: (NSString *) _str
|
- (NSString *) labelForKey: (NSString *) _str
|
||||||
withResourceManager: (WOResourceManager *) rm
|
withResourceManager: (WOResourceManager *) rm
|
||||||
{
|
{
|
||||||
NSArray *languages;
|
|
||||||
NSString *lKey, *lTable, *lVal;
|
NSString *lKey, *lTable, *lVal;
|
||||||
NSRange r;
|
NSRange r;
|
||||||
|
|
||||||
|
@ -546,10 +547,6 @@ static SoProduct *commonProduct = nil;
|
||||||
if (rm == nil)
|
if (rm == nil)
|
||||||
[self warnWithFormat:@"missing resource manager!"];
|
[self warnWithFormat:@"missing resource manager!"];
|
||||||
|
|
||||||
/* lookup languages */
|
|
||||||
|
|
||||||
languages = [context resourceLookupLanguages];
|
|
||||||
|
|
||||||
/* get parameters */
|
/* get parameters */
|
||||||
|
|
||||||
r = [_str rangeOfString:@"/"];
|
r = [_str rangeOfString:@"/"];
|
||||||
|
@ -710,9 +707,27 @@ static SoProduct *commonProduct = nil;
|
||||||
- (WOResponse *) redirectToLocation: (NSString *) newLocation
|
- (WOResponse *) redirectToLocation: (NSString *) newLocation
|
||||||
{
|
{
|
||||||
WOResponse *response;
|
WOResponse *response;
|
||||||
|
NSURL *url;
|
||||||
|
NSMutableString *location;
|
||||||
|
NSString *theme, *query;
|
||||||
|
|
||||||
|
location = [NSMutableString stringWithString: newLocation];
|
||||||
|
theme = [[context request] formValueForKey: @"theme"];
|
||||||
|
if ([theme length])
|
||||||
|
{
|
||||||
|
url = [NSURL URLWithString: newLocation];
|
||||||
|
query = [url query];
|
||||||
|
if ([query length])
|
||||||
|
{
|
||||||
|
if ([query rangeOfString: @"theme="].length == 0)
|
||||||
|
[location appendFormat: @"&theme=%@", theme];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[location appendFormat: @"?theme=%@", theme];
|
||||||
|
}
|
||||||
|
|
||||||
response = [self responseWithStatus: 302];
|
response = [self responseWithStatus: 302];
|
||||||
[response setHeader: newLocation forKey: @"location"];
|
[response setHeader: location forKey: @"location"];
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue