コード例 #1
0
 public StringOutput contextHelpWithWrapper(String page) {
   StringOutput sb = new StringOutput(192);
   if (ContextHelpModule.isContextHelpEnabled()) {
     HelpModule helpModule = CoreSpringFactory.getImpl(HelpModule.class);
     Locale locale = renderer.getTranslator().getLocale();
     String url = helpModule.getHelpProvider().getURL(locale, page);
     if (url != null) {
       sb.append("<span class=\"o_chelp_wrapper\">")
           .append("<a href=\"")
           .append(url)
           .append("\" class=\"o_chelp\" target=\"_blank\"><i class='o_icon o_icon_help'></i> ")
           .append(renderer.getTranslator().translate("help"))
           .append("</a></span>");
     }
   }
   return sb;
 }
コード例 #2
0
 /**
  * @param packageName
  * @param pageName
  * @param hoverTextKey
  * @return
  */
 public StringOutput contextHelp(String packageName, String pageName, String hoverTextKey) {
   StringOutput sb = new StringOutput(100);
   if (ContextHelpModule.isContextHelpEnabled()) {
     String hooverText = renderer.getTranslator().translate(hoverTextKey);
     if (hooverText != null) {
       hooverText = StringEscapeUtils.escapeHtml(hooverText);
     }
     sb.append("<a href=\"javascript:");
     sb.append(contextHelpJSCommand(packageName, pageName));
     sb.append("\" title=\"")
         .append(hooverText)
         .append("\" class=\"o_chelp\"><i class='o_icon o_icon_help'></i> ");
     sb.append(renderer.getTranslator().translate("help"));
     sb.append("</a>");
   }
   return sb;
 }
コード例 #3
0
 /**
  * Method to translate a key that comes from another package. This should be used rarely. When a
  * key is used withing multiple packages is is usually better to use a fallback translator or to
  * move the key to the default packages.
  *
  * <p>Used in context help system
  *
  * @param bundleName the package name, e.g. 'org.olat.core'
  * @param key the key, e.g. 'my.key'
  * @param args optional arguments, null if not used
  * @return
  */
 public String translateWithPackage(String bundleName, String key, String[] args) {
   Translator pageTrans = renderer.getTranslator();
   if (pageTrans == null) return "{Translator is null: key_to_translate=" + key + "}";
   Locale locale = pageTrans.getLocale();
   Translator tempTrans = new PackageTranslator(bundleName, locale);
   String result = tempTrans.translate(key, args);
   if (result == null) {
     return "{Invalid bundle name: " + bundleName + " and key: " + key + "}";
   }
   return result;
 }
コード例 #4
0
 /**
  * Create a js command to open a specific context help page
  *
  * @param packageName
  * @param pageName
  * @return
  */
 public StringOutput contextHelpJSCommand(String packageName, String pageName) {
   StringOutput sb = new StringOutput(100);
   if (ContextHelpModule.isContextHelpEnabled()) {
     String langCode = renderer.getTranslator().getLocale().toString();
     sb.append("contextHelpWindow('");
     Renderer.renderNormalURI(sb, "help/");
     sb.append(langCode).append("/").append(packageName).append("/").append(pageName);
     sb.append("')");
   }
   return sb;
 }
コード例 #5
0
 /**
  * @param key
  * @return
  */
 public String translate(String key) {
   Translator trans = renderer.getTranslator();
   if (trans == null) return "{Translator is null: key_to_translate=" + key + "}";
   String res = trans.translate(key);
   if (res == null)
     return "?? key not found to translate: key_to_translate="
         + key
         + " / trans info:"
         + trans
         + "}";
   return res;
 }
コード例 #6
0
 /**
  * Create a link that can be used within a context help page to link to another context help page
  * from another package. As link text the page title is used.
  *
  * @param bundleName e.g. "org.olat.core"
  * @param pageName e.g. "my-page.html"
  * @return
  */
 public StringOutput contextHelpRelativeLink(String bundleName, String pageName) {
   String linkText;
   int lastDotPos = pageName.lastIndexOf(".");
   if (lastDotPos != -1) {
     Translator pageTrans = renderer.getTranslator();
     if (bundleName != null) {
       Locale locale = pageTrans.getLocale();
       pageTrans = new PackageTranslator(bundleName, locale);
     }
     linkText = pageTrans.translate("chelp." + pageName.subSequence(0, lastDotPos) + ".title");
   } else {
     linkText = pageName; // fallback
   }
   return contextHelpRelativeLink(bundleName, pageName, linkText);
 }
コード例 #7
0
 public String formatDateAndTime(Date date) {
   Formatter f = Formatter.getInstance(renderer.getTranslator().getLocale());
   return f.formatDateAndTime(date);
 }