Search in sources :

Example 6 with LanguageConfiguration

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;
}
Also used : LanguageConfiguration(org.olat.course.site.model.LanguageConfiguration)

Example 7 with LanguageConfiguration

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;
}
Also used : SiteDefinition(org.olat.core.gui.control.navigation.SiteDefinition) OLATResourceable(org.olat.core.id.OLATResourceable) RepositoryManager(org.olat.repository.RepositoryManager) RepositoryEntry(org.olat.repository.RepositoryEntry) CourseSiteConfiguration(org.olat.course.site.model.CourseSiteConfiguration) LanguageConfiguration(org.olat.course.site.model.LanguageConfiguration)

Example 8 with LanguageConfiguration

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;
}
Also used : LanguageConfiguration(org.olat.course.site.model.LanguageConfiguration)

Example 9 with LanguageConfiguration

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);
}
Also used : StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) FlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiCellRenderer) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) RepositoryEntry(org.olat.repository.RepositoryEntry) StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) LanguageConfiguration(org.olat.course.site.model.LanguageConfiguration) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Example 10 with LanguageConfiguration

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;
}
Also used : SiteDefinition(org.olat.core.gui.control.navigation.SiteDefinition) CourseSiteConfiguration(org.olat.course.site.model.CourseSiteConfiguration) LanguageConfiguration(org.olat.course.site.model.LanguageConfiguration)

Aggregations

LanguageConfiguration (org.olat.course.site.model.LanguageConfiguration)10 SiteDefinition (org.olat.core.gui.control.navigation.SiteDefinition)4 CourseSiteConfiguration (org.olat.course.site.model.CourseSiteConfiguration)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)2 FlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiCellRenderer)2 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)2 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)2 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)2 SiteSecurityCallback (org.olat.core.gui.control.navigation.SiteSecurityCallback)2 OLATResourceable (org.olat.core.id.OLATResourceable)2 UserSession (org.olat.core.util.UserSession)2 RepositoryManager (org.olat.repository.RepositoryManager)2