Index: lams_common/src/java/org/lamsfoundation/lams/util/CSSThemeUtil.java =================================================================== diff -u -rb576ec837a4c8f685d38140ac52362fe98acf89e -r903c94bada901b0af715bbaf728ce49fa887c326 --- lams_common/src/java/org/lamsfoundation/lams/util/CSSThemeUtil.java (.../CSSThemeUtil.java) (revision b576ec837a4c8f685d38140ac52362fe98acf89e) +++ lams_common/src/java/org/lamsfoundation/lams/util/CSSThemeUtil.java (.../CSSThemeUtil.java) (revision 903c94bada901b0af715bbaf728ce49fa887c326) @@ -34,77 +34,74 @@ import org.lamsfoundation.lams.web.util.AttributeNames; public class CSSThemeUtil { - - // private static Logger log = Logger.getLogger(CSSThemeUtil.class); - public static String DEFAULT_HTML_THEME = "defaultHTML"; - - /** - * Will return a list of stylesheets for the current user. - * If the user does not have a specific stylesheet, then - * the default stylesheet will be included in this list. - * The default stylesheet will always be included in this list. - * @return - */ - public static List getAllUserThemes() - { - List themeList = new ArrayList(); - - // Always have default as that defines everything. Other themes - // define changes. - - themeList.add(DEFAULT_HTML_THEME); + // private static Logger log = Logger.getLogger(CSSThemeUtil.class); + public static String DEFAULT_HTML_THEME = "defaultHTML"; + /** + * Will return a list of stylesheets for the current user. If the user does + * not have a specific stylesheet, then the default stylesheet will be + * included in this list. The default stylesheet will always be included in + * this list. + * + * @return + */ + public static List getAllUserThemes() { + List themeList = new ArrayList(); - boolean userThemeFound = false; - HttpSession ss = SessionManager.getSession(); - if ( ss != null ) { - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - if ( user != null ) { - CSSThemeBriefDTO theme = user.getHtmlTheme(); - - if (theme != null ) { - userThemeFound = true; - String themeName = theme.getName(); - if ( themeName != null && ! isLAMSDefaultTheme(themeName) ) { - themeList.add(theme.getName()); - } - } - } - - } - - // if we haven't got a user theme, we are probably on the login page - // so we'd better include the default server theme (if it isn't the LAMS default theme - if ( !userThemeFound ) { - String serverDefaultTheme = Configuration.get(ConfigurationKeys.DEFAULT_HTML_THEME); - if ( serverDefaultTheme != null && ! serverDefaultTheme.equals(DEFAULT_HTML_THEME) ) { - themeList.add(serverDefaultTheme); - } - } - - return themeList; + // Always have default as that defines everything. Other themes + // define changes. + + themeList.add(DEFAULT_HTML_THEME); + + boolean userThemeFound = false; + HttpSession ss = SessionManager.getSession(); + if (ss != null) { + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + if (user != null) { + CSSThemeBriefDTO theme = user.getHtmlTheme(); + + if (theme != null) { + userThemeFound = true; + String themeName = theme.getName(); + if (themeName != null && !isLAMSDefaultTheme(themeName)) { + themeList.add(theme.getName()); + } + } + } + } - - public static CSSThemeBriefDTO getUserTheme() - { - CSSThemeBriefDTO theme = null; - - HttpSession ss = SessionManager.getSession(); - if ( ss != null ) { - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - if ( user != null ) { - theme = user.getHtmlTheme(); - } - } - - return theme; - + + // if we haven't got a user theme, we are probably on the login page + // so we'd better include the default server theme (if it isn't the LAMS default theme + if (!userThemeFound) { + String serverDefaultTheme = Configuration.get(ConfigurationKeys.DEFAULT_HTML_THEME); + if (serverDefaultTheme != null && !serverDefaultTheme.equals(DEFAULT_HTML_THEME)) { + themeList.add(serverDefaultTheme); + } } - - // Is this theme the LAMS basic theme, which must always be included on a web page? - // This is NOT the server default theme - which may be a custom theme. - public static boolean isLAMSDefaultTheme(String themeName) { - return themeName.equals(DEFAULT_HTML_THEME); + + return themeList; + } + + public static CSSThemeBriefDTO getUserTheme() { + CSSThemeBriefDTO theme = null; + + HttpSession ss = SessionManager.getSession(); + if (ss != null) { + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + if (user != null) { + theme = user.getHtmlTheme(); + } } + + return theme; + + } + + // Is this theme the LAMS basic theme, which must always be included on a web page? + // This is NOT the server default theme - which may be a custom theme. + public static boolean isLAMSDefaultTheme(String themeName) { + return themeName.equals(DEFAULT_HTML_THEME); + } }