Index: lams_central/src/java/org/lamsfoundation/lams/web/tag/CssTag.java =================================================================== diff -u -r8ba43ae6cd465e24431866147a53ae7e43102efd -r32e3881bd897cb6c7fc274a5ba1fbedec9e4c865 --- lams_central/src/java/org/lamsfoundation/lams/web/tag/CssTag.java (.../CssTag.java) (revision 8ba43ae6cd465e24431866147a53ae7e43102efd) +++ lams_central/src/java/org/lamsfoundation/lams/web/tag/CssTag.java (.../CssTag.java) (revision 32e3881bd897cb6c7fc274a5ba1fbedec9e4c865) @@ -24,6 +24,9 @@ import java.io.IOException; +import java.util.Iterator; +import java.util.List; + import javax.servlet.http.HttpSession; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; @@ -35,6 +38,7 @@ import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.Configuration; import org.lamsfoundation.lams.util.ConfigurationKeys; +import org.lamsfoundation.lams.util.CSSThemeUtil; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -55,7 +59,9 @@ public class CssTag extends TagSupport { private static final Logger log = Logger.getLogger(CssTag.class); - + + private boolean generateLocalLink = false; + /** * */ @@ -64,35 +70,69 @@ } public int doStartTag() throws JspException { +// String customStylesheetLink = null; +// String serverURL = Configuration.get(ConfigurationKeys.SERVER_URL); +// +// HttpSession ss = SessionManager.getSession(); +// if ( ss != null ) { +// UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); +// if ( user != null ) { +// CSSThemeVisualElement theme = user.getTheme(); +// if ( theme != null && theme.getName() != null ) { +// customStylesheetLink = generateLink(theme.getName(),serverURL); +// } +// } +// } +// +// try { +// JspWriter writer = pageContext.getOut(); +// if ( customStylesheetLink != null ) { +// writer.print(customStylesheetLink); +// } +// writer.print(generateLink("default",serverURL)); +// } catch ( IOException e ) { +// log.error("CssTag unable to write out CSS details due to IOException.", e); +// // don't throw a JSPException as we want the system to still function. +// } +// + String customStylesheetLink = null; - String serverURL = Configuration.get(ConfigurationKeys.SERVER_URL); + String serverURL = Configuration.get(ConfigurationKeys.SERVER_URL); + List themeList = CSSThemeUtil.getAllUserThemes(); - HttpSession ss = SessionManager.getSession(); - if ( ss != null ) { - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - if ( user != null ) { - CSSThemeVisualElement theme = user.getTheme(); - if ( theme != null && theme.getName() != null ) { - customStylesheetLink = generateLink(theme.getName(),serverURL); - } - } - } - - try { - JspWriter writer = pageContext.getOut(); - if ( customStylesheetLink != null ) { - writer.print(customStylesheetLink); - } - writer.print(generateLink("default",serverURL)); - } catch ( IOException e ) { - log.error("CssTag unable to write out CSS details due to IOException.", e); - // don't throw a JSPException as we want the system to still function. + Iterator i = themeList.iterator(); + + while (i.hasNext()) + { + String theme = (String)i.next(); + if ( theme != null) { + if (generateLocalLink) + customStylesheetLink = generateLocalLink(theme,serverURL); + else + customStylesheetLink = generateLink(theme,serverURL); + } + + try { + JspWriter writer = pageContext.getOut(); + if ( customStylesheetLink != null ) { + writer.print(customStylesheetLink); + } + //writer.print(generateLink("default",serverURL)); + } catch ( IOException e ) { + log.error("CssTag unable to write out CSS details due to IOException.", e); + // don't throw a JSPException as we want the system to still function. + } } return SKIP_BODY; } - private String generateLink(String stylesheetName, String serverURL) { + private String generateLocalLink(String stylesheetName, String serverURL) { + return ""; + } + + private String generateLink(String stylesheetName, String serverURL) + { if ( serverURL.endsWith("/") ) { return ""; } else { @@ -104,4 +144,12 @@ return EVAL_PAGE; } + public void setLocalLink(String localLink) + { + if (localLink.equalsIgnoreCase("true")) + this.generateLocalLink = true; + else + this.generateLocalLink = false; + } + }