1 22 23 package org.meshcms.webui; 24 25 import java.util.*; 26 import org.meshcms.core.*; 27 import org.meshcms.util.*; 28 29 32 public class Help { 33 public static final String CONFIGURE = "configure"; 34 public static final String CONTROL_PANEL = "control_panel"; 35 public static final String EDIT_PAGE = "edit_page"; 36 public static final String EDIT_PROFILE = "edit_profile"; 37 public static final String FILE_MANAGER = "file_manager"; 38 public static final String PAGE_MANAGER = "page_manager"; 39 public static final String NEW_PAGE = "create_new_page"; 40 public static final String NEW_USER = "new_user"; 41 public static final String SITE_MANAGER = "site_manager"; 42 public static final String STATIC_EXPORT = "static_export"; 43 public static final String UNZIP = "unzip"; 44 public static final String UPLOAD = "upload"; 45 public static final String MODULES = "modules"; 46 47 private static Properties args; 48 49 static { 50 args = new Properties(); 51 args.setProperty(EDIT_PAGE, "ch04s02.html"); 52 args.setProperty(NEW_PAGE, "ch04s03.html"); 53 args.setProperty(CONTROL_PANEL, "ch05.html"); 54 args.setProperty(PAGE_MANAGER, "ch05s01.html"); 55 args.setProperty(CONFIGURE, "ch05s02.html"); 56 args.setProperty(EDIT_PROFILE, "ch05s03.html"); 57 args.setProperty(NEW_USER, "ch05s04.html"); 58 args.setProperty(FILE_MANAGER, "ch05s05.html"); 59 args.setProperty(UPLOAD, "ch05s05.html#upload"); 60 args.setProperty(UNZIP, "ch05s05.html#unzip"); 61 args.setProperty(STATIC_EXPORT, "ch05s06.html"); 62 args.setProperty(SITE_MANAGER, "ch05s07.html"); 63 args.setProperty(MODULES, "ch06s01.html"); 64 } 65 66 69 public static String icon(WebSite webSite, String contextPath, 70 String argument, UserInfo userInfo) { 71 return icon(webSite, contextPath, argument, userInfo, null, false); 72 } 73 74 public static String icon(WebSite webSite, String contextPath, 75 String argument, UserInfo userInfo, String anchor, boolean grayIcon) { 76 String lang = getHelpLang(webSite, userInfo); 77 78 return "<img SRC='" + contextPath + '/' + webSite.getAdminPath() + 79 "/images/" + (grayIcon ? "small_help_gray.gif" : "small_help.gif") + 80 "' title='Help: " + argument + 81 "' alt='Help Icon' onclick=\"javascript:window.open('" + 82 contextPath + '/' + webSite.getAdminPath() + "/help/" + lang + 83 '/' + args.getProperty(argument, "index.html") + 84 (Utils.isNullOrEmpty(anchor) ? "" : "#" + anchor) + 85 "', 'meshcmshelp', 'width=740,height=560,menubar=no,status=yes,toolbar=no,resizable=yes,scrollbars=yes').focus();\" />"; 86 } 87 88 public static String getHelpLang(WebSite webSite, UserInfo userInfo) { 89 String lang = "en"; 90 91 if (userInfo != null) { 92 String otherLang = userInfo.getPreferredLocaleCode(); 93 94 if (webSite.getFile(webSite.getAdminPath().add("help", otherLang)).exists()) { 95 lang = otherLang; 96 } 97 } 98 99 return lang; 100 } 101 } 102 | Popular Tags |