Add support for themes
This commit is contained in:
parent
da5ada9d98
commit
fd895b757b
|
@ -40,10 +40,18 @@
|
|||
NSMutableArray *languages;
|
||||
NSArray *browserLanguages;
|
||||
SOGoUser *user;
|
||||
NSString *language;
|
||||
NSString *language, *theme;
|
||||
|
||||
languages = [NSMutableArray array];
|
||||
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"])
|
||||
{
|
||||
browserLanguages = [[self request] browserLanguages];
|
||||
|
@ -57,14 +65,6 @@
|
|||
[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;
|
||||
}
|
||||
|
||||
|
|
|
@ -273,10 +273,18 @@
|
|||
- (NSString *) pageJavaScriptURL
|
||||
{
|
||||
WOComponent *page;
|
||||
NSString *filename;
|
||||
NSString *theme, *filename;
|
||||
|
||||
page = [context page];
|
||||
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);
|
||||
|
||||
return [self urlForResourceFilename: filename];
|
||||
|
@ -285,10 +293,19 @@
|
|||
- (NSString *) productJavaScriptURL
|
||||
{
|
||||
WOComponent *page;
|
||||
NSString *filename;
|
||||
NSString *theme, *filename;
|
||||
|
||||
page = [context page];
|
||||
[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);
|
||||
|
||||
return [self urlForResourceFilename: filename];
|
||||
|
|
|
@ -113,8 +113,9 @@
|
|||
|
||||
rm = [self pageResourceManager];
|
||||
|
||||
return [rm pathForResourceNamed: rn inFramework: fw
|
||||
languages: [[self context] resourceLookupLanguages]];
|
||||
return [rm pathForResourceNamed: rn
|
||||
inFramework: fw
|
||||
languages: languages];
|
||||
}
|
||||
|
||||
- (id)loadToolbarConfigFromResourceNamed:(NSString *)_name {
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
NSCalendarDate *_selectedDate;
|
||||
NSDictionary *locale;
|
||||
SOGoUserDefaults *userDefaults;
|
||||
NSArray *languages;
|
||||
}
|
||||
|
||||
+ (NSArray *) monthLabelKeys;
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#import <SOGo/SOGoUser.h>
|
||||
#import <SOGo/SOGoUserFolder.h>
|
||||
#import <SOGo/SOGoUserDefaults.h>
|
||||
#import <SOGo/WOContext+SOGo.h>
|
||||
#import <SOGo/WOResourceManager+SOGo.h>
|
||||
|
||||
#import "UIxJSClose.h"
|
||||
|
@ -149,6 +150,7 @@ static SoProduct *commonProduct = nil;
|
|||
if (!userDefaults)
|
||||
ASSIGN (userDefaults, [SOGoSystemDefaults sharedSystemDefaults]);
|
||||
language = [userDefaults language];
|
||||
ASSIGN (languages, [context resourceLookupLanguages]);
|
||||
ASSIGN (locale,
|
||||
[[self resourceManager] localeForLanguageNamed: language]);
|
||||
}
|
||||
|
@ -536,7 +538,6 @@ static SoProduct *commonProduct = nil;
|
|||
- (NSString *) labelForKey: (NSString *) _str
|
||||
withResourceManager: (WOResourceManager *) rm
|
||||
{
|
||||
NSArray *languages;
|
||||
NSString *lKey, *lTable, *lVal;
|
||||
NSRange r;
|
||||
|
||||
|
@ -546,10 +547,6 @@ static SoProduct *commonProduct = nil;
|
|||
if (rm == nil)
|
||||
[self warnWithFormat:@"missing resource manager!"];
|
||||
|
||||
/* lookup languages */
|
||||
|
||||
languages = [context resourceLookupLanguages];
|
||||
|
||||
/* get parameters */
|
||||
|
||||
r = [_str rangeOfString:@"/"];
|
||||
|
@ -710,9 +707,27 @@ static SoProduct *commonProduct = nil;
|
|||
- (WOResponse *) redirectToLocation: (NSString *) newLocation
|
||||
{
|
||||
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 setHeader: newLocation forKey: @"location"];
|
||||
[response setHeader: location forKey: @"location"];
|
||||
|
||||
return response;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue