use of com.haulmont.cuba.core.global.GlobalConfig in project cuba by cuba-platform.
the class SiteSettings method getFreeMarkerSettings.
public Properties getFreeMarkerSettings() {
GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
Map<String, Locale> availableLocales = globalConfig.getAvailableLocales();
if (availableLocales.isEmpty()) {
throw new IllegalStateException("Property cuba.availableLocales is not configured");
}
Locale locale = availableLocales.values().iterator().next();
FormatStrings formatStrings = formatStringsRegistry.getFormatStrings(locale);
final Properties freemarkerSettings = new Properties();
freemarkerSettings.setProperty("number_format", "#");
freemarkerSettings.setProperty("datetime_format", formatStrings.getDateTimeFormat());
freemarkerSettings.setProperty("date_format", formatStrings.getDateFormat());
freemarkerSettings.setProperty("template_exception_handler", "rethrow");
return freemarkerSettings;
}
use of com.haulmont.cuba.core.global.GlobalConfig in project cuba by cuba-platform.
the class CubaUIProvider method getTheme.
@Override
public String getTheme(UICreateEvent event) {
// get theme from cookies before app ui initialized for smooth theme enabling
WebConfig webConfig = configuration.getConfig(WebConfig.class);
GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class);
String appWindowTheme = webConfig.getAppWindowTheme();
String userAppTheme = getCookieValue(event.getRequest().getCookies(), App.APP_THEME_COOKIE_PREFIX + globalConfig.getWebContextName());
if (userAppTheme != null) {
if (!Objects.equals(userAppTheme, appWindowTheme)) {
// check theme support
ThemeConstantsRepository themeRepository = AppBeans.get(ThemeConstantsRepository.NAME);
Set<String> supportedThemes = themeRepository.getAvailableThemes();
if (supportedThemes.contains(userAppTheme)) {
return userAppTheme;
}
}
}
return super.getTheme(event);
}
Aggregations