Index: lams_central/src/java/org/lamsfoundation/lams/web/tag/HelpTag.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/tag/HelpTag.java,v diff -u -r1.11 -r1.12 --- lams_central/src/java/org/lamsfoundation/lams/web/tag/HelpTag.java 11 Jan 2008 01:53:49 -0000 1.11 +++ lams_central/src/java/org/lamsfoundation/lams/web/tag/HelpTag.java 11 Feb 2008 00:37:17 -0000 1.12 @@ -56,6 +56,10 @@ */ public class HelpTag extends TagSupport { + private static final String LAMSFOUNDATION_TEXT = "lamsfoundation"; + private static final String LAMSDOCS = "lamsdocs"; + private static final String ENGLISH_LANGUAGE = "en"; + private static final Logger log = Logger.getLogger(HelpTag.class); private String module = null; private String page = null; @@ -71,10 +75,6 @@ public int doStartTag() throws JspException { try { - HttpSession session = ((HttpServletRequest) this.pageContext.getRequest()).getSession(); - - String language = null; - String country = null; String helpURL = null; String fullURL = null; @@ -86,12 +86,6 @@ } try { - Locale locale = (Locale) session.getAttribute(LocaleFilter.PREFERRED_LOCALE_KEY); - if ( locale != null ) { - language = locale.getLanguage(); - country = locale.getCountry(); - } - if(toolSignature != null && module != null) { // retrieve help URL for tool ILamsToolService toolService = (ILamsToolService) getContext().getBean(AuthoringConstants.TOOL_SERVICE_BEAN_NAME); @@ -103,16 +97,16 @@ return SKIP_BODY; // construct link - fullURL = helpURL + module + "#" + toolSignature + module + "-" + language + country; + helpURL = addLanguageToURL(helpURL); + fullURL = helpURL + module + "#" + toolSignature + module; writer.println(""); } else if(page != null){ - String anchorPrefix = page.replaceAll("[+\\s]", ""); - - fullURL = Configuration.get(ConfigurationKeys.HELP_URL) +page+ "#" +anchorPrefix+ "-" + language + country; + helpURL = addLanguageToURL(Configuration.get(ConfigurationKeys.HELP_URL)); + fullURL = helpURL+page; writer.println(""); @@ -135,6 +129,22 @@ return SKIP_BODY; } + private String addLanguageToURL(String helpURL) { + + HttpSession session = ((HttpServletRequest) this.pageContext.getRequest()).getSession(); + Locale locale = (Locale) session.getAttribute(LocaleFilter.PREFERRED_LOCALE_KEY); + if ( locale != null ) { + String language = locale.getLanguage(); + + if ( ! ENGLISH_LANGUAGE.equals(language) && helpURL.indexOf(LAMSFOUNDATION_TEXT) != -1 ) { + // points to the LAMS Foundation site, so add the language to the path. + return helpURL.replace(LAMSDOCS, LAMSDOCS+language); + } + } + + return helpURL; + } + public int doEndTag() { return EVAL_PAGE; }