use of org.olat.course.site.model.LanguageConfiguration in project OpenOLAT by OpenOLAT.
the class CourseSiteDef method getLanguageConfiguration.
protected LanguageConfiguration getLanguageConfiguration(UserRequest ureq, CourseSiteConfiguration config) {
if (config == null || config.getConfigurations() == null)
return null;
String language = ureq.getUserSession().getLocale().getLanguage();
LanguageConfiguration myLangConfig = null;
LanguageConfiguration defaultLangConfig = null;
for (LanguageConfiguration langConfig : config.getConfigurations()) {
if (langConfig.isDefaultConfiguration()) {
defaultLangConfig = langConfig;
}
if (language.equals(langConfig.getLanguage())) {
myLangConfig = langConfig;
}
}
if (myLangConfig == null) {
myLangConfig = defaultLangConfig;
}
if (myLangConfig == null && config.getConfigurations().size() > 0) {
myLangConfig = config.getConfigurations().get(0);
}
return myLangConfig;
}
use of org.olat.course.site.model.LanguageConfiguration in project OpenOLAT by OpenOLAT.
the class CourseSiteContextEntryControllerCreator method getRepositoryEntry.
private RepositoryEntry getRepositoryEntry(UserRequest ureq, ContextEntry ce) {
if (repoEntry == null) {
if (ce.getOLATResourceable() instanceof RepositoryEntry) {
repoEntry = (RepositoryEntry) ce.getOLATResourceable();
} else {
OLATResourceable ores = ce.getOLATResourceable();
if ("CourseSite".equals(ores.getResourceableTypeName())) {
int id = ores.getResourceableId().intValue();
CourseSiteDef courseSiteDef = null;
List<SiteDefinition> siteDefList = getSitesDefinitions().getSiteDefList();
if (id == 2) {
for (SiteDefinition siteDef : siteDefList) {
if (siteDef instanceof CourseSiteDef2) {
courseSiteDef = (CourseSiteDef) siteDef;
}
}
} else if (id == 1) {
for (SiteDefinition siteDef : siteDefList) {
if (siteDef instanceof CourseSiteDef) {
courseSiteDef = (CourseSiteDef) siteDef;
}
}
}
if (courseSiteDef != null) {
CourseSiteConfiguration config = courseSiteDef.getCourseSiteconfiguration();
LanguageConfiguration langConfig = courseSiteDef.getLanguageConfiguration(ureq, config);
if (langConfig != null) {
String softKey = langConfig.getRepoSoftKey();
RepositoryManager rm = RepositoryManager.getInstance();
repoEntry = rm.lookupRepositoryEntryBySoftkey(softKey, false);
}
}
} else {
RepositoryManager rm = RepositoryManager.getInstance();
repoEntry = rm.lookupRepositoryEntry(ores.getResourceableId());
}
}
}
return repoEntry;
}
use of org.olat.course.site.model.LanguageConfiguration in project openolat by klemens.
the class CourseSiteDef method getLanguageConfiguration.
protected LanguageConfiguration getLanguageConfiguration(UserRequest ureq, CourseSiteConfiguration config) {
if (config == null || config.getConfigurations() == null)
return null;
String language = ureq.getUserSession().getLocale().getLanguage();
LanguageConfiguration myLangConfig = null;
LanguageConfiguration defaultLangConfig = null;
for (LanguageConfiguration langConfig : config.getConfigurations()) {
if (langConfig.isDefaultConfiguration()) {
defaultLangConfig = langConfig;
}
if (language.equals(langConfig.getLanguage())) {
myLangConfig = langConfig;
}
}
if (myLangConfig == null) {
myLangConfig = defaultLangConfig;
}
if (myLangConfig == null && config.getConfigurations().size() > 0) {
myLangConfig = config.getConfigurations().get(0);
}
return myLangConfig;
}
use of org.olat.course.site.model.LanguageConfiguration in project openolat by klemens.
the class CourseSiteAdminController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("admin.menu.title");
enableToolbar = uifactory.addCheckboxesHorizontal("site.enable.toolbar", "site.enable.toolbar", formLayout, new String[] { "x" }, new String[] { "" });
enableToolbar.addActionListener(FormEvent.ONCHANGE);
if (siteConfiguration.isToolbar()) {
enableToolbar.select("x", true);
}
String cssClass = siteConfiguration.getNavIconCssClass();
iconCssClassEl = uifactory.addTextElement("site.iconCssClass", "site.icon", 32, cssClass, formLayout);
FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CSCols.defLanguage.i18nKey(), CSCols.defLanguage.ordinal()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CSCols.language.i18nKey(), CSCols.language.ordinal()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CSCols.title.i18nKey(), CSCols.title.ordinal()));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(false, CSCols.courseId.i18nKey(), CSCols.courseId.ordinal(), false, null));
FlexiCellRenderer renderer = new StaticFlexiCellRenderer("openre", new TextFlexiCellRenderer());
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(CSCols.courseTitle.i18nKey(), CSCols.courseTitle.ordinal(), "openre", renderer));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select"));
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("remove", translate("remove"), "remove"));
String page = velocity_root + "/lang_options.html";
tableLayout = FormLayoutContainer.createCustomFormLayout("site.options.lang", getTranslator(), page);
tableLayout.setRootForm(mainForm);
tableLayout.setLabel("site.courses", null);
formLayout.add(tableLayout);
model = new CourseSiteDataModel(columnsModel);
List<LanguageConfigurationRow> configs = new ArrayList<LanguageConfigurationRow>();
Map<String, LanguageConfiguration> langToConfigMap = new HashMap<String, LanguageConfiguration>();
if (siteConfiguration.getConfigurations() != null) {
for (LanguageConfiguration langConfig : siteConfiguration.getConfigurations()) {
langToConfigMap.put(langConfig.getLanguage(), langConfig);
}
}
for (String langKey : i18nModule.getEnabledLanguageKeys()) {
if (langToConfigMap.containsKey(langKey)) {
LanguageConfiguration langConfig = langToConfigMap.get(langKey);
RepositoryEntry re = repositoryManager.lookupRepositoryEntryBySoftkey(langConfig.getRepoSoftKey(), false);
configs.add(new LanguageConfigurationRow(langConfig, re, tableLayout));
} else {
configs.add(new LanguageConfigurationRow(new LanguageConfiguration(langKey), null, tableLayout));
}
}
model.setObjects(configs);
tableEl = uifactory.addTableElement(getWindowControl(), "languageTable", model, getTranslator(), tableLayout);
tableEl.setRendererType(FlexiTableRendererType.classic);
tableEl.setCustomizeColumns(true);
tableEl.setAndLoadPersistedPreferences(ureq, "course-site-admin");
FormLayoutContainer buttonsLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonsLayout);
okButton = uifactory.addFormLink("save", "save", null, buttonsLayout, Link.BUTTON);
okButton.setCustomEnabledLinkCSS("btn btn-primary");
// uifactory.addFormSubmitButton("save", "save", formLayout);
}
use of org.olat.course.site.model.LanguageConfiguration in project openolat by klemens.
the class CourseSiteContextEntryControllerCreator method getCourseSite.
private CourseSiteDef getCourseSite(UserRequest ureq, RepositoryEntry re) {
if (re == null)
return null;
List<SiteDefinition> siteDefList = getSitesDefinitions().getSiteDefList();
for (SiteDefinition siteDef : siteDefList) {
if (siteDef instanceof CourseSiteDef) {
CourseSiteDef courseSiteDef = (CourseSiteDef) siteDef;
CourseSiteConfiguration config = courseSiteDef.getCourseSiteconfiguration();
LanguageConfiguration langConfig = courseSiteDef.getLanguageConfiguration(ureq, config);
if (langConfig == null)
continue;
String softKey = langConfig.getRepoSoftKey();
if (re.getSoftkey() != null && re.getSoftkey().equals(softKey)) {
return courseSiteDef;
}
}
}
return null;
}
Aggregations