Index: lams_admin/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e -r7998a31f6d7d4f1eef3e866bafef22caa012eb7a --- lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) +++ lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 7998a31f6d7d4f1eef3e866bafef22caa012eb7a) @@ -411,5 +411,8 @@ admin.themes.makeDefault =Make default admin.themes.deleteConfirm =Are you sure you want to delete this theme? admin.themes.nameAlreadyExists =Please enter a new unused theme name, or click the edit icon to edit. +admin.themes.type =Type +admin.themes.html =HTML +admin.themes.flash =Flash #======= End labels: Exported 391 labels for en AU ===== Index: lams_admin/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e -r7998a31f6d7d4f1eef3e866bafef22caa012eb7a --- lams_admin/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) +++ lams_admin/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 7998a31f6d7d4f1eef3e866bafef22caa012eb7a) @@ -411,5 +411,8 @@ admin.themes.makeDefault =Make default admin.themes.deleteConfirm =Are you sure you want to delete this theme? admin.themes.nameAlreadyExists =Please enter a new unused theme name, or click the edit icon to edit. +admin.themes.type =Type +admin.themes.html =HTML +admin.themes.flash =Flash #======= End labels: Exported 391 labels for en AU ===== Index: lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java =================================================================== diff -u -r16a173502ea5c23248e95a73afd859ea77d0ac23 -r7998a31f6d7d4f1eef3e866bafef22caa012eb7a --- lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java (.../ImportService.java) (revision 16a173502ea5c23248e95a73afd859ea77d0ac23) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java (.../ImportService.java) (revision 7998a31f6d7d4f1eef3e866bafef22caa012eb7a) @@ -46,7 +46,7 @@ import org.lamsfoundation.lams.admin.web.dto.V1OrgRightDTO; import org.lamsfoundation.lams.admin.web.dto.V1OrganisationDTO; import org.lamsfoundation.lams.admin.web.dto.V1UserDTO; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.usermanagement.AuthenticationMethod; import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.OrganisationState; @@ -657,7 +657,7 @@ } String flashId = parseStringCell(row.getCell(FLASH_THEME)); - CSSThemeVisualElement flashTheme = getFlashTheme(flashId); + Theme flashTheme = getFlashTheme(flashId); if (flashTheme==null) { args[0] = "("+flashId+")"; rowResult.add(messageService.getMessage("error.flash.theme.invalid", args)); @@ -667,7 +667,7 @@ } String htmlId = parseStringCell(row.getCell(HTML_THEME)); - CSSThemeVisualElement htmlTheme = getHtmlTheme(htmlId); + Theme htmlTheme = getHtmlTheme(htmlId); if (htmlTheme==null) { args[0] = "("+htmlId+")"; rowResult.add(messageService.getMessage("error.html.theme.invalid", args)); @@ -850,26 +850,26 @@ return true; } - // set CSSThemeVisualElement to default flash theme if cell is empty - private CSSThemeVisualElement getFlashTheme(String flashId){ + // set Theme to default flash theme if cell is empty + private Theme getFlashTheme(String flashId){ if (flashId==null || flashId=="") { return service.getDefaultFlashTheme(); } else { try { - return (CSSThemeVisualElement)service.findById(CSSThemeVisualElement.class, new Long(flashId)); + return (Theme)service.findById(Theme.class, new Long(flashId)); } catch (Exception e) { return null; } } } - // set CSSThemeVisualElement to default html theme if cell is empty - private CSSThemeVisualElement getHtmlTheme(String htmlId){ + // set Theme to default html theme if cell is empty + private Theme getHtmlTheme(String htmlId){ if (htmlId==null || htmlId=="") { return service.getDefaultHtmlTheme(); } else { try { - return (CSSThemeVisualElement)service.findById(CSSThemeVisualElement.class, new Long(htmlId)); + return (Theme)service.findById(Theme.class, new Long(htmlId)); } catch (Exception e) { return null; } Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java =================================================================== diff -u -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e -r7998a31f6d7d4f1eef3e866bafef22caa012eb7a --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java (.../ThemeManagementAction.java) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java (.../ThemeManagementAction.java) (revision 7998a31f6d7d4f1eef3e866bafef22caa012eb7a) @@ -33,7 +33,7 @@ import org.lamsfoundation.lams.admin.service.AdminServiceProxy; import org.lamsfoundation.lams.admin.web.form.ThemeForm; import org.lamsfoundation.lams.config.ConfigurationItem; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.themes.service.IThemeService; import org.lamsfoundation.lams.usermanagement.Role; import org.lamsfoundation.lams.util.CSSThemeUtil; @@ -59,32 +59,33 @@ private static IThemeService themeService; private static Configuration configurationService; - public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // check permission if (!request.isUserInRole(Role.SYSADMIN)) { request.setAttribute("errorName", "RegisterAction"); - request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext()) - .getMessage("error.authorisation")); + request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext()).getMessage("error.authorisation")); return mapping.findForward("error"); } if (themeService == null) { themeService = AdminServiceProxy.getThemeService(getServlet().getServletContext()); } - List themes = themeService.getAllThemes(); + // Get all the themes + List themes = themeService.getAllThemes(); - String currentTheme = Configuration.get(ConfigurationKeys.DEFAULT_HTML_THEME); - for (CSSThemeVisualElement theme : themes) { + // Flag the default and un-editable themes + String currentCSSTheme = Configuration.get(ConfigurationKeys.DEFAULT_HTML_THEME); + String currentFlashTheme = Configuration.get(ConfigurationKeys.DEFAULT_FLASH_THEME); + for (Theme theme : themes) { theme.setCurrentDefaultTheme(Boolean.FALSE); - if (theme.getName().equals(currentTheme)) { + if (theme.getName().equals(currentCSSTheme) || theme.getName().equals(currentFlashTheme)) { theme.setCurrentDefaultTheme(Boolean.TRUE); } theme.setNotEditable(Boolean.FALSE); - if (theme.getName().equals(CSSThemeUtil.DEFAULT_HTML_THEME)) { + if (theme.getName().equals(CSSThemeUtil.DEFAULT_HTML_THEME) || theme.getName().equals(CSSThemeUtil.DEFAULT_FLASH_THEME)) { theme.setNotEditable(Boolean.TRUE); } } @@ -93,54 +94,77 @@ return mapping.findForward("success"); } - public ActionForward addOrEditTheme(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + public ActionForward addOrEditTheme(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ThemeForm themeForm = (ThemeForm) form; - CSSThemeVisualElement theme = null; + // Update the theme + Theme theme = null; if (themeForm.getId() != null && themeForm.getId() != 0) { theme = themeService.getTheme(themeForm.getId()); } else { - theme = new CSSThemeVisualElement(); + theme = new Theme(); } updateThemeFromForm(theme, themeForm); - themeService.saveOrUpdateTheme(theme); + // Set the theme as default, or disable it as default. + // Disabling restores the system default if (themeForm.getCurrentDefaultTheme() != null && themeForm.getCurrentDefaultTheme() == true) { - Configuration.updateItem(ConfigurationKeys.DEFAULT_HTML_THEME, themeForm.getName()); - getConfiguration().persistUpdate(); - } else { - String currentTheme = Configuration.get(ConfigurationKeys.DEFAULT_HTML_THEME); - if (themeForm.getName().equals(currentTheme)) { - Configuration.updateItem(ConfigurationKeys.DEFAULT_HTML_THEME, CSSThemeUtil.DEFAULT_HTML_THEME); + if (Integer.parseInt(themeForm.getType()) == Theme.TYPE_CSS) { + Configuration.updateItem(ConfigurationKeys.DEFAULT_HTML_THEME, themeForm.getName()); getConfiguration().persistUpdate(); + } else { + Configuration.updateItem(ConfigurationKeys.DEFAULT_FLASH_THEME, themeForm.getName()); + getConfiguration().persistUpdate(); } + } else { + if (Integer.parseInt(themeForm.getType()) == Theme.TYPE_CSS) { + String currentTheme = Configuration.get(ConfigurationKeys.DEFAULT_HTML_THEME); + if (themeForm.getName().equals(currentTheme)) { + Configuration.updateItem(ConfigurationKeys.DEFAULT_HTML_THEME, CSSThemeUtil.DEFAULT_HTML_THEME); + getConfiguration().persistUpdate(); + } + } else { + String currentTheme = Configuration.get(ConfigurationKeys.DEFAULT_FLASH_THEME); + if (themeForm.getName().equals(currentTheme)) { + Configuration.updateItem(ConfigurationKeys.DEFAULT_FLASH_THEME, CSSThemeUtil.DEFAULT_FLASH_THEME); + getConfiguration().persistUpdate(); + } + } } themeForm.clear(); return unspecified(mapping, themeForm, request, response); } - public ActionForward removeTheme(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + public ActionForward removeTheme(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { + + // Remove the theme ThemeForm themeForm = (ThemeForm) form; if (themeForm.getId() != null) { themeService.removeTheme(themeForm.getId()); } - String currentTheme = Configuration.get(ConfigurationKeys.DEFAULT_HTML_THEME); - if (themeForm.getName().equals(currentTheme)) { - Configuration.updateItem(ConfigurationKeys.DEFAULT_HTML_THEME, CSSThemeUtil.DEFAULT_HTML_THEME); - getConfiguration().persistUpdate(); + // If it was the default, restore the system default + if (Integer.parseInt(themeForm.getType()) == Theme.TYPE_CSS) { + String currentTheme = Configuration.get(ConfigurationKeys.DEFAULT_HTML_THEME); + if (themeForm.getName().equals(currentTheme)) { + Configuration.updateItem(ConfigurationKeys.DEFAULT_HTML_THEME, CSSThemeUtil.DEFAULT_HTML_THEME); + getConfiguration().persistUpdate(); + } + } else { + String currentTheme = Configuration.get(ConfigurationKeys.DEFAULT_FLASH_THEME); + if (themeForm.getName().equals(currentTheme)) { + Configuration.updateItem(ConfigurationKeys.DEFAULT_FLASH_THEME, CSSThemeUtil.DEFAULT_FLASH_THEME); + getConfiguration().persistUpdate(); + } } themeForm.clear(); return unspecified(mapping, themeForm, request, response); } - public ActionForward setAsDefault(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + public ActionForward setAsDefault(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ThemeForm themeForm = (ThemeForm) form; if (themeForm.getName() != null) { Configuration.updateItem(ConfigurationKeys.DEFAULT_HTML_THEME, themeForm.getName()); @@ -150,18 +174,17 @@ return unspecified(mapping, themeForm, request, response); } - private CSSThemeVisualElement updateThemeFromForm(CSSThemeVisualElement theme, ThemeForm form) { + private Theme updateThemeFromForm(Theme theme, ThemeForm form) { theme.setName(form.getName()); theme.setDescription(form.getDescription()); theme.setImageDirectory(form.getImageDirectory()); - theme.setTheme(Boolean.TRUE); + theme.setType(Integer.parseInt(form.getType())); return theme; } private Configuration getConfiguration() { if (configurationService == null) { - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() - .getServletContext()); + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext()); configurationService = (Configuration) ctx.getBean("configurationService"); } Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java =================================================================== diff -u -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e -r7998a31f6d7d4f1eef3e866bafef22caa012eb7a --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java (.../ThemeForm.java) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java (.../ThemeForm.java) (revision 7998a31f6d7d4f1eef3e866bafef22caa012eb7a) @@ -44,6 +44,7 @@ private String description; private String imageDirectory; private Boolean currentDefaultTheme; + private String type; public String getMethod() { return method; @@ -81,14 +82,20 @@ public void setCurrentDefaultTheme(Boolean currentDefaultTheme) { this.currentDefaultTheme = currentDefaultTheme; } - + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } public void clear() { this.method = null; this.id = null; this.name = null; this.description = null; this.imageDirectory = null; this.currentDefaultTheme = null; + this.type = null; } } Index: lams_admin/web/themeManagement.jsp =================================================================== diff -u -r4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e -r7998a31f6d7d4f1eef3e866bafef22caa012eb7a --- lams_admin/web/themeManagement.jsp (.../themeManagement.jsp) (revision 4abf8ee86bc60a0b94edfdc4c907c28c6c5df13e) +++ lams_admin/web/themeManagement.jsp (.../themeManagement.jsp) (revision 7998a31f6d7d4f1eef3e866bafef22caa012eb7a) @@ -3,7 +3,7 @@